Remove meta description on certain pages

You should be able to remove the existing description tag with the following code: remove_action( ‘wp_head’, ‘_wp_render_title_tag’, 1 ); Put the above snippet inside the same function you are using to conditionally add a new tag so there is always only a single description tag at a time.

Modifying meta tags after doing ajax call in plugin

It took me a while of tinkering with the hooks, but in the end, I fixed it by loading the post earlier. Instead of loop_start: $this->loader->add_action(‘loop_start’, $plugin_public, ‘mp_display_post’); I used get_header: $this->loader->add_action(‘get_header’, $plugin_public, ‘mp_display_post’); This worked properly because now the post information is loaded before wp_head gets called, and therefore I can use the loaded … Read more

Custom plugin – $post_id in wp_head

Use get_queried_object_id() to get the post ID of the current page/post when viewing a single page or post, regardless of whether or not you’re in the loop, or what the global $post variable happens to be at that moment: if ( is_page() || is_single() ) { $post_id = get_queried_object_id(); $meta_alternate = get_post_meta( $post_id, ‘extra_meta_alternate’, true … Read more

adding meta data using plugin to top of head

Okay, here’s the answer: function CustomHead() { include(‘headcontent.php’); } add_action(‘wp_head’,’CustomHead’,1,1); The key is that first “1”, which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: http://codex.wordpress.org/Function_Reference/add_action

storing wp_head in a variable?

This function doesn’t take any params, so there is no nice way of doing it. But of course you can do this PHP way using output buffering 😉 ob_start(); wp_head(); $var = ob_get_clean();