Woocommerce SEO -- Noindex 'Order by' 存档

Woocommerce SEO -- Noindex 'Order by' archive

我在要排序的类别档案中遇到重复标题和重复元描述问题。

虽然其他 sub-pages 正确无索引,但重复问题出现在 1 日的以下模式中。

/product-category/name/
/product-category/name/?orderby=dat
/product-category/name/?orderby=menu_order
/product-category/name/?orderby=price-desc
/product-category/name/?orderby=price

我正在使用 Yoast SEO 插件,我们如何从排序中不索引这些档案?

在您的 functions.php

中使用此代码
add_action( 'wp_head', 'cp_prevent_indexing_orderby' );

if(!function_exists('cp_prevent_indexing_orderby')){
    function cp_prevent_indexing_orderby () {
        if (isset($_GET['orderby'])){
            echo '<meta name="robots" content="noindex, nofollow">';
        }
    }
}