无法删除 wordpress 中的操作 noindex [英] Cannot remove action noindex in wordpress
本文介绍了无法删除 wordpress 中的操作 noindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经做了一些研究并运行了这段代码
I've done some research and run up with this code
remove_action('wp_head','noindex',1);
但显然它没有删除我的 WordPress 标题中的 <meta name="robots" content="noindex,follow"/>
.我正在使用 WordPress 4.2.3
but apparently it's not removing the <meta name="robots" content="noindex,follow"/>
in my WordPress header. I'm using WordPress 4.2.3
推荐答案
使用 wp_robots WordPress 5.7.0 中引入的钩子,用于过滤机器人元标记输出.
Use the wp_robots hook introduced in WordPress 5.7.0 to filter its robots meta tag output.
示例函数:
add_filter( 'wp_robots', 'wp_robots_remove_noindex', 999 );
function wp_robots_remove_noindex( $robots ){
//put any conditionals here to target certain pages
if ( is_search() || is_archive( ) || is_404( ) ) {
//set the index and noindex array items
$robots[ 'index' ] = true;
$robots[ 'noindex' ] = false;
}
return $robots;
}
这将导致以下输出:<meta name='robots' content='index, follow'/>
这篇关于无法删除 wordpress 中的操作 noindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文