Hi! I am trying to figure out how to inject custom code into the <head> section per post. All of the plugins I’m looking at seem like they just do it site wide with per post exceptions. I need the opposite of that.
I can write one if I need to but am trying to avoid it if I can.
Take a look at wp code snippets
If you’re comfortable with PHP you could probably write this using conditionals either in functions.php or in header.php.
Use wp_head action
function inject_code_per_post() {
// Your custom post head injection code
}
add_action( ‘wp_head’, ‘inject_code_per_post’);
Use ACF to add a custom post field in the header.php
I should add that I want to customize what gets injected on each post. Ideally there is a snippet field on each post that I can customize.