How to disable Yoast SEO on specific pages

If you’re using the Yoast SEO plugin on your WordPress site, you may want to disable the plugin on specific pages. This post will show you how to disable Yoast SEO on specific pages. This can be helpful if you want to use a different SEO plugin or just don’t need all of Yoast’s features on certain pages. Let’s get started!

shopify yoast app

You will need to add this code to your Functions.php file:

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_single ( 1 ) ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

        remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
    }
}

The above example is set to disable Yoast 14.0+ on page id 1.

To specify which pages you want disabled:

Web Page

Example of how to disable several page types:

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_page ( [ 4321, 8765, 11109 ] ) ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

        remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
    }
}

Blog Post

Example of how to disable several blog posts:

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_single( [ 1234, 5678, 91011 ] ) ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

        remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
    }
}

Category

Example of how to disable Custom Post Types:

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_singular( 'custom_posttype_name' ) ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

        remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
    }
}

How to Edit Functions.php file in WordPress

  1. Launch your favorite FTP client and connect to the hosting server remotely.
  2. Navigate to “/wp-content/themes/” folder.
  3. Open your active theme and locate the functions.php file.
  4. Edit and save the modified content.

How to find your Page ID in WordPress

To find your page IDs in WordPress, hover over the page title in the backend and look at the URL at the bottom of your screen.

e.g.,

Conclusion

As you can see, disabling Yoast SEO on specific pages is quite a simple process. Just remember that if you make any changes to your code, be sure to back up your site first! And if you need help with this or other WordPress issues, our team is always happy and available to lend a helping hand.

FAQs

  • What happens if I deactivate Yoast?
  • Why do I need Yoast?
  • Is Yoast still the best?

Published on: 2022-10-19
Updated on: 2022-11-23

Avatar for Isaac Adams-Hands

Isaac Adams-Hands

Isaac Adams-Hands is the SEO Director at SEO North, a company that provides Search Engine Optimization services. As an SEO Professional, Isaac has considerable expertise in On-page SEO, Off-page SEO, and Technical SEO, which gives him a leg up against the competition.