Yoast SEO is the most popular WordPress SEO plugin. This plugin adds meta tags on a page to optimize the page on different platforms like Search Engines, Facebook, Twitter, etc. Those meta tags actually decide how your website looks on those different platforms.
Although every meta tag has unique functionality, sometimes you might want to remove one or more meta tags from a specific page(s). You might want to remove Yoast SEO meta tag(s) if the plugin generates a wrong/unnecessary one or if a page meta tags are dedicated to another plugin.
Remove Yoast SEO Header Meta Tags
You can easily remove Yoast SEO meta tags by customizing the plugin filter hooks. Filter hooks are available for almost all meta tags, thanks to Yoast for available hooks!
For example, add the custom function to remove description meta <meta name="description" ••/>
tag from “About” page, where 'about'
is the page slug for the page.
// Remove Yoast meta description tag
add_filter( 'wpseo_metadesc', 'remove_yoast_meta_description' );
function remove_yoast_meta_description( $myfilter ) {
if ( is_page ( 'about' ) ) {
return false;
}
return $myfilter;
}
If you want to apply this for another page, just replace 'about'
with the page slug you want to apply the function. You can use conditional tags to specify the function where you want to apply.
You can remove other meta tags too. To remove other meta tags, replace wpseo_metadesc
with the meta filter hook you want to remove. Here’s the list of filter hooks with their header meta output:
Yoast SEO Filter Hook | HTML Meta Output (•• = Dynamic) |
wpseo_title | <title>••</title>** |
wpseo_robots | <meta name=”robots” ••/> |
wpseo_canonical | <link rel=”canonical” ••/> |
wpseo_metadesc | <meta name=”description” ••/> |
wpseo_metakeywords | <meta name=”keywords” ••/> |
wpseo_locale | <meta property=”og:locale” ••/> |
wpseo_opengraph_title | <meta property=”og:title” ••/> |
wpseo_opengraph_desc | <meta property=”og:description” ••/> |
wpseo_opengraph_url | <meta property=”og:url” ••/> |
wpseo_opengraph_type | <meta property=”og:type” ••/> |
wpseo_opengraph_image | <meta property=”og:image#” ••/> |
wpseo_opengraph_site_name | <meta property=”og:site_name” ••/> |
wpseo_opengraph_admin | <meta property=”fb:admins” ••/> |
wpseo_opengraph_author_facebook | <meta property=”article:author” ••/> |
wpseo_opengraph_show_publish_date | <meta property=”article:published_time” ••/> |
wpseo_twitter_title | <meta name=”twitter:title” ••/> |
wpseo_twitter_description | <meta name=”twitter:description” ••/> |
wpseo_twitter_card_type | <meta name=”twitter:card” ••/> |
wpseo_twitter_site | <meta name=”twitter:site” ••/> |
wpseo_twitter_image | <meta name=”twitter:image” ••/> |
wpseo_twitter_creator_account | <meta name=”twitter:creator” ••/> |
wpseo_json_ld_output | <script type=’application/ld+json’>••</script> |
** <title>
meta tag cannot be removed, return false
to ignore Yoast SEO title and print default page title.
Removing Multiple Yoast Meta Tags
You can also remove multiple meta tags from a page. For example, use the following function to remove canonical meta tag and description meta tag from the “About” page:
// Remove multiple Yoast meta tags
add_filter( 'wpseo_canonical', 'remove_multiple_yoast_meta_tags' );
add_filter( 'wpseo_metadesc', 'remove_multiple_yoast_meta_tags' );
function remove_multiple_yoast_meta_tags( $myfilter ) {
if ( is_page ( 'about' ) ) {
return false;
}
return $myfilter;
}
You can combine all the filters to a custom function just like this. That’s how you can remove duplicate meta tags or unwanted meta tags from a page easily.
Adding code snippets for the first time? Don’t know where and how to add the code snippets? Read our in-depth article on how to add code snippets to a WordPress site.
That’s all for today! If you face problems, don’t forget to leave a comment.
i need remove all yoast tags in all page post pagination etc. Pls help me!
“need to remove all yoast tags in all page post pagination”
Then you should uninstall the plugin. What’s the use of the plugin?
I only use Yoast for sitemaps, seo benchmark points and reading points. just love this feature. and I need to remove all meta tags. 🙂 excuse see that there is a shortcut that will allow me to remove meta tags in bulk.
Thanks this helps me out so much. How did you find out about all these hooks?
Other hooks are working except the opengraphs specifically the image?
if i want to combine this two
With
what is the correct code?
You can’t combine these in a tiny function as they have different filters, different return values, and different conditionals! Just put them separately.
omg i love this hook this help me so much because my teacher did not help as you did