Disable Wordpress Yoast SEO on Single Page

admin

Administrator
Staff member
I'm attempting to disable the Wordpress Yoast SEO on a single page because it's conflicting with a different plugin.

I tried following this <a href="https://stackoverflow.com/questions/24391891/remove-yoast-wordpress-seo-on-a-page">StackOverflow question</a>, adding this code to <strong>functions.php</strong>:

Code:
add_action('template_redirect','remove_wpseo');

function remove_wpseo(){
    if ( is_page(944)) {
      global $wpseo_front;
      remove_action( 'wp_head', array($wpseo_front, 'head'), 2 ); // &lt;-- check priority
    }
}

The above did not work, so I then ran across <a href="https://wordpress.org/support/topic/remove-yoast-on-certain-pages-no-longer-working-after-update" rel="nofollow noreferrer">this post</a>, and tried to change it to below, which of course resulted in a 500 error.

Code:
add_action('template_redirect','remove_wpseo');

function remove_wpseo(){
   if ( is_page(5526)) {
     global WPSEO_Frontend::get_instance()
     remove_action( 'wp_head', array(WPSEO_Frontend::get_instance(), 'head'), 2 ); // &lt;-- check priority
   }
}

Any ideas on how I might go about disabling Yoast SEO on a single page? Should I do this from <strong>functions.php</strong> or somewhere else? I think I'm close, but not quite there.