Archived topic
Add PHP code just before </head>
5 replies · Started by Butch Pornebo on October 4, 2022
Would like to insert the following php code just before </head>
<?php the_field(‘some_script_before_head_closing'); ?>
What hook should I use?
Hi there,
Try wp_head hook.
I want to make sure that the php code will be inserted just before </head> and whatever else in front of it. right?
Hi Butch,
Yes, if you want it inside <head> </head>, using hook wp_head should work.
how do I make that the code I'm adding is the last one before the </head>?
e.g.
<head>
..... some other code
..... some other code
..... some other code
... my code
</head>
Set the priority to a really high value like 999999.