30 WordPress中robots' content='noindex, follow头部标签怎么去掉?

WordPress的搜索页面头部有这个标签:<meta name='robots' content='noindex, follow, max-image-preview:large' />

导致搜索引擎不索引这个页面,怎么去掉这个标签?

在header.php文件里没有看到这个代码啊,急!!!!!

请先 登录 后评论

1 个回答

这个代码不在主题里,在wp_head()函数里,你可以这样去掉:

在主题文件夹里找到functions.php这个文件,然后在有add_filter的附近,加上下面这段代码,刷新一下,搜索页面的robots标签就消失了!

	add_filter('wp_robots', 'fanly_basic_robots_remove_noindex', 999);
	function fanly_basic_robots_remove_noindex( $robots ){
	    return get_option('blog_public') ? [] : $robots;
	    
	}
请先 登录 后评论