删除页面上的 Yoast WordPress SEO [英] Remove Yoast WordPress SEO on a page

查看:37
本文介绍了删除页面上的 Yoast WordPress SEO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除某个页面上的 Yoast WordPress SEO,因为它与另一个插件冲突.

I am trying to remove the Yoast WordPress SEO on a certain page because it is conflicting with another plugin.

我尝试将下面的代码添加到我的functions.php,但它似乎不起作用,感谢任何帮助.

I tried adding the code below to my functions.php but it does not seem to work, any help is appreciated.

谢谢

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');

推荐答案

入队不是删除动作的合适时机,请改用 template_redirect :

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
    }
}

检查插件用于添加 wp_head 操作的优先级,因为删除必须相同,如果为空,则无.

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.

这篇关于删除页面上的 Yoast WordPress SEO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆