0

我正在为各种事情使用美妙的 Yoast 插件,但主要用于无索引和无关注页面。我们是一个基于 PPC 的网站,因此我们删除了搜索。现在客户想要它回来,但我需要 wordpress 内置搜索不返回大量无索引页面。

我知道您可以内置排除各种元描述。

我打算将此作为一个开始: https ://css-tricks.com/forums/topic/using-wps-pre_get_posts-to-exclude-post-with-meta_key/

问题 - 我要查找的术语是什么 - meta-no-index=no??

为什么 Yoast 默认不这样做?

4

1 回答 1

0

您需要编辑由 wp_head() 函数输出的机器人元标记。

如果使用 Yoast,这是用于更改机器人元标记内容的 WP 过滤器:

add_filter('wpseo_robots', 'yoast_no_search_noindex', 999);
function yoast_no_search_noindex($string= "") {
    if (is_search()) {
        $string= "index,follow";
    }
    return $string;
}

https://wordpress.stackexchange.com/questions/136220/remove-meta-robots-tag-from-wp-head

于 2017-12-14T02:11:58.070 回答