最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to remove index meta tag <meta name="robots" content="index, follow"&am

programmeradmin3浏览0评论

I need to remove this line <meta name="robots" content="index, follow"> on my site for the accessibility mode.

I successfully added the <meta name="robots" content="noindex, follow"> by calling add_action( 'wp_head', 'wp_no_robots', 1); but it shows both metatags

 <meta name="robots" content="noindex,follow"> <meta name="robots" content="index, follow">  

I didn't find the way to remove the index metatag line.

I need to remove this line <meta name="robots" content="index, follow"> on my site for the accessibility mode.

I successfully added the <meta name="robots" content="noindex, follow"> by calling add_action( 'wp_head', 'wp_no_robots', 1); but it shows both metatags

 <meta name="robots" content="noindex,follow"> <meta name="robots" content="index, follow">  

I didn't find the way to remove the index metatag line.

Share Improve this question edited Feb 26, 2021 at 16:12 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Feb 26, 2021 at 15:28 princeexpeditionprinceexpedition 237 bronze badges 4
  • You've tagged this question with plugin-all-in-one-seo - are you using the plugin? – kero Commented Feb 26, 2021 at 15:33
  • 1 Nope, I do not use any plugin for <meta name="robots" content="index, follow">. But I am using a custom plugin for enabling/disabling to the accessibility mode where I simply adding these lines add_action( 'wp_head', 'wp_no_robots', 1); I kept looking the way to remove the robots metatag. even through I tried this statement remove_action( 'wp_head', 'robots'); but no luck so far. – princeexpedition Commented Feb 26, 2021 at 15:46
  • Ok, sorry but I can't help you with that as I'm unfamiliar with the core robots stuff. Somebody else will probably pick it up - just wanted to make sure it is about WP core and not a plugin. – kero Commented Feb 26, 2021 at 16:05
  • 1 make.wordpress/core/2021/02/19/… – birgire Commented Feb 26, 2021 at 23:00
Add a comment  | 

1 Answer 1

Reset to default 1

Rather than using the

add_action( 'wp_head', 'wp_no_robots', 1 );

Try using

add_filter( 'wp_robots', 'wp_robots_no_robots' );

In your code you are actually trying to add one more function call to pre called function rather than just changing its value to noindex. Use add_filter instead. :)

发布评论

评论列表(0)

  1. 暂无评论