首页 文章

Woocommerce SEO - Noindex 'Order by'存档

提问于
浏览
0

我在分类档案上有重复 Headers 和重复元描述问题 .

虽然其他子页面未正确编制索引,但重复问题将在第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插件,我们如何从Sorting中取消索引这些档案?

1 回答

  • 1

    在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">';
            }
        }
    }
    

相关问题