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');
Just in case someone is wondering why above methods are not working after the upgrade, this is the new method of disabling Yoast SEO output as of version 14.0
Hope this helps!
Enqueing is not the right moment to remove an action, use
template_redirect
instead: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.
@jhashane answer is correct as a straight forward answer to the question as it is. However, this removes the
<tite>
tag as well, and other default worpdress meta, as long as Yoast is active and installed. It just kills the output handled by Yoast.Disable Yoast components might be a better approach most of the time. Conflicts are often about Yoast taking over some meta, specially types or social open graphs.
We spend hours to understand the new 14.0 version. As of Yoast SEO 14.0 the plugin is more like Danish Lego and building up the head meta tags as “presenters”.
EX: Remove all social media components output on page id 123:
The filter in this example is very late. You can still use individual meta or schema etc etc filters to filter the content configuration and settings. And when you partial manually wanna disable your configuration, on page basis or so, remove “blocks” of Yoast do in your source code:
Remove everything except document title and description on pages:
In this case, you should use the
wpseo_title
etc etc filters to enable och disable Yoast content, and use WordPress default content on certain selected post or pages.Some meta still have the old filter(s) left to turn different “grouped” output on or off Like
add_filter('wpseo_output_twitter_card', '__return_false' );
But Facebook for example, is part of the opengraph, shared by other social media. There is no explicit Facebook opengraph filter. And in the future, we will have more social media and other tags shared components.Common default presenters: (dump of
$presenters
)Finally, here is an example of “conflicts with other plugin”. We needed to remove open graphs when plugin “Groups” restricted a page. We don wanna share or give meta for sharing here. Either, Yoast should not add this page to the sitemap, and the robots must be set as noindex. All this is decided by a custom meta on the page we talking about:
Sitemap case: We still need a separate filter process for the sitemap as it might be loaded by ajax or cron/ not rendered as head output:
Please comment to add another approach or trix.