I am working on a custom post type and I don't want it to get all the clutter from wp_head()
. However, I do want to show a specific hook, for example the YoastSEO meta tags.
How do I call a specific single hook in the template file without wp_head()
? I tried adding a filter to wp_head
that removes the parts I don't want, e.g.:
if ( 'customtype' === get_post_type() )
{
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'feed_links' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
}
However, this seems inefficient and I would have to maintain any additional plugins or functions that manipulate or add actions to wp_head()
.
Is there a way to remove ALL actions and keep the one(s) I want? I'd prefer not including wp_head
at all and just call whatever action I need for that custom post type.
wp_head
, or removingwp_head()
completely is stupid and suicidle. This will break a huge amount of other things which I can gaurentee you you will come back to ask questions about.wp_head()
is as important as to an engine to a car