How To Disable Yoast SEO Output in WordPress

⏲️ Estimated reading time: 3 min

How To Disable Yoast SEO Output in WordPress. If you need to disable Yoast SEO’s output on specific posts, pages, or custom post types, you can achieve this by adding a simple code snippet to your theme’s functions.php file. This guide will show you how to remove Yoast SEO output based on different conditions.

Disable Globally or for Specific Posts

To disable Yoast SEO output on the homepage, front page, or for specific posts, add the following code to your functions.php file:

<?php
/**
 * Disable Yoast SEO output
 */

add_action( 'template_redirect', 'remove_wpseo' );

/**
 * Removes output from Yoast SEO on the frontend for a specific post, page, or custom post type.
 */
function remove_wpseo() {
    
    if ( is_home() || is_front_page() ){
		$front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

		remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
	}
    
    if (is_single()) {
		$front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

		remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
	}
}
How To Disable Yoast SEO Output in WordPress

Explanation:

  • The code hooks into template_redirect to remove the Yoast SEO meta output.
  • is_home() and is_front_page() conditions ensure that Yoast SEO is disabled for the homepage and front page.
  • is_single() ensures that Yoast SEO is removed for all single post pages.

Disable Yoast SEO for a Specific Page

To apply this to a specific page, use is_page:

if ( is_page ( 1 ) ) { //... }

Disable Yoast SEO for Multiple Posts or Pages

To disable the output for multiple posts or pages, pass an array of post IDs:

if ( is_single( [ 123456, 234567, 345678 ] ) ) { //... }

or for pages:

if ( is_page( [ 123456, 234567, 345678 ] ) ) { //... }

Disable Yoast SEO for a Custom Post Type

If you want to remove output for an entire custom post type, use is_singular:

if ( is_singular( 'my_custom_posttype' ) ) { //... }

This method ensures that Yoast SEO’s metadata is removed from all posts under the specified custom post type.

Final Notes

  • Always back up your functions.php file before making modifications.
  • If your website is running a child theme, add the code to the child theme’s functions.php file instead.
  • Test changes in a staging environment before deploying them live.

By using these methods, you can control where Yoast SEO outputs metadata, improving flexibility in your WordPress setup.

Tags: WordPress, Yoast SEO, SEO Optimization, Remove Yoast Metadata, WordPress Functions, WordPress SEO, Disable Yoast, Custom Post Types, Functions.php, WordPress Development

Report an issue (max 5 words):

We store the message, post link, time, and IP (for abuse prevention). No account required.

Want to support us? Let friends in on the secret and share your favorite post!

2 online now

Live Referrers

No external referrers recorded for this post.

Photo of author

Flo

How To Disable Yoast SEO Output in WordPress

Published

Update

Welcome to HelpZone.blog, your go-to hub for expert insights, practical tips, and in-depth guides across technology, lifestyle, business, entertainment, and more! Our team of passionate writers and industry experts is dedicated to bringing you the latest trends, how-to tutorials, and valuable advice to enhance your daily life. Whether you're exploring WordPress tricks, gaming insights, travel hacks, or investment strategies, HelpZone is here to empower you with knowledge. Stay informed, stay inspired because learning never stops! 🚀

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.