【问题标题】:wordpress search should not return no-index'd pageswordpress 搜索不应返回无索引的页面
【发布时间】:2016-12-21 12:14:23
【问题描述】:

我正在使用出色的 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 默认不这样做?

【问题讨论】:

    标签: wordpress noindex yoast


    【解决方案1】:

    您需要编辑由 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-05
      • 2013-08-28
      • 2013-01-12
      • 2011-07-29
      • 1970-01-01
      相关资源
      最近更新 更多