奇怪的是,\\u yoast\\u wpseo\\u meta-robots-noindex不是上钩的hookr.io.
您知道有一个脚本可以删除Yoast在noindex页面上的rel=canonical输出吗?
奇怪的是,\\u yoast\\u wpseo\\u meta-robots-noindex不是上钩的hookr.io.
您知道有一个脚本可以删除Yoast在noindex页面上的rel=canonical输出吗?
不确定是否有任何插件可以做到这一点。但是,根据我的测试,下面这样一个简单的删除规范URL的函数似乎可以工作。
function wpse282643()
{
global $post;
// Check if WPSEO plugin is active and bail immediately if not (this is just a sample check)
if ( ! defined( \'WPSEO_VERSION\' ) ) {
return;
}
// Check if current page/post has noindex set
$noindex = \\WPSEO_Meta::get_value( \'meta-robots-noindex\', $post->ID );
if ( \'1\' === $noindex ) {
// Remove canonical URL
remove_action( \'wpseo_head\', [ \\WPSEO_Frontend::get_instance(), \'canonical\' ], 20 );
}
}
add_action( \'template_redirect\', \'wpse282643\', 99 );