Ad

Woocommerce SEO -- Noindex 'Order By' Archive

- 1 answer

I'm having the Duplicate Title & Duplicate Meta Description issues on Category archives for Sorting.

While other sub-pages are correctly noindexed, the duplicate issue appears at following pattern on 1st.

/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

I'm using Yoast SEO plugin, How do we noindex these archives from Sorting ?

Ad

Answer

Use this code in your 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">';
        }
    }
}
Ad
source: stackoverflow.com
Ad