Noindex Woocommerce Attributes ?

  • Hello,
    how can i set the attributes archive pages to noindex ???

    Also i have a problem that product attribute archive pages like this

    domain.de/manufacturer/suplight/

    redirect to my homepage domain.de

    I don’t have these archives 100%! Disabled all, but they can be typed in and redirected to the frontpage.

    b. regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi,
    i found the problem of the redirect. it was an related post plugin who does that redirect.

    However how can i set all Woocommerce attributes pages to noindex ?
    If i add new products, new attributes are added which get fast indexed by google.

    I want them all on noindex.

    b. regards

    Hello,

    Thank you for contacting Rank Math today.

    I am glad that you were able to fix the redirection issue. In regards to the other issue, you can set the product attributes to noindex by doing the following:

    1). Create a custom function to check product attribute pages as shown below:

    function custom_is_wc_attribute() {
    
        if ( is_tax() && function_exists( 'taxonomy_is_product_attribute') ) { 
            // now we know for sure that the queried object is a taxonomy
            $tax_obj = get_queried_object();
            return taxonomy_is_product_attribute( $tax_obj->taxonomy );
        }
        return false;
    }

    2). Add the following code to set these pages to noindex:

    /**
     * Modify Rank Math robots meta data.
     * Targeting product attribute pages
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
            if(custom_is_wc_attribute()){
               $robots['index'] = 'noindex';
               return $robots;
            }
    	return $robots;
    });

    Both of these snippets should be added to your theme’s functions.php file.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘Noindex Woocommerce Attributes ?’ is closed to new replies.