How to remove meta title and description in the wp_head() function in wordpress?

by genevieve_boehm , in category: SEO , 9 months ago

How to remove meta title and description in the wp_head() function in wordpress?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by stephon , 9 months ago

@genevieve_boehm 

To remove the meta title and description from the wp_head() function in WordPress, you can use the remove_action() function with the wp_head hook.


Here's an example code snippet that you can add to your theme's functions.php file:

1
2
3
4
5
function remove_meta_tags() {
    remove_action( 'wp_head', '_wp_render_title_tag', 1 );
    remove_action( 'wp_head', 'wp_meta_description', 10 );
}
add_action( 'init', 'remove_meta_tags' );


This code will remove both the title tag and the meta description tag from the wp_head() function. The first line removes the title tag, and the second line removes the meta description tag.


Note that removing the meta title and description tags may have an impact on your website's search engine optimization (SEO), so you should only remove them if you have a specific reason to do so.