I am trying to remove the Yoast WordPress SEO on a certain page because it is conflicting with another plugin.
I tried adding the code below to my functions.php but it does not seem to work, any help is appreciated.
Thank You
function remove_wpseo(){
if ( is_page(944)) {
global $wpseo_front;
remove_action( 'wp_head', array($wpseo_front, 'head'), 2 );
}
}
add_action('wp_enqueue_scripts','remove_wpseo');
Enqueing is not the right moment to remove an action, use template_redirect
instead:
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 ); // <-- check priority
}
}
Check the priority that the plugin uses to add the wp_head
action as the removal has to be the same and none if empty.
Just in case someone still needs this. This worked for me. Change 'page' to 'post' if it's a blog post. Instead of trying to throw out Yoast completely, just hide the meta box.
add_action( 'add_meta_boxes', 'remove_post_meta_boxes', 11 );
function remove_post_meta_boxes() {
if( isset( $_GET['post'] ) && $_GET['post'] == '22' ) {
remove_meta_box( 'wpseo_meta', 'page', 'normal' );
}
}