0

WooCommerce is creating category pagination pages for parent categories. We don't want these indexed, but I can't work out how best to do this.

For instance I have https://www.i-hled.co.uk/product-category/light-engines/led-count-one/page/2/

This goes up to page 31, but I only want the main category page indexed not these paginated pages. This is NOT a site wide requirement, I still want other pages pagination to index, so I can't make a global change.

I've looked at the following

<meta name="robots" content="follow, <?php echo 
(get_query_var('paged')==1)?'index':'noindex'?>" /><meta name="robots" 
content="follow, <?php echo (get_query_var('paged')==1)?'index':'noindex'? 
>" />

But that removes all pagination indexing

Also I thought of something along these lines in the header, but I can't work out how this would work with pagination.

if ( is_product_category(led-count-one){
echo "<meta name=\"robots\" content=\"noindex\" />";
}

Is there a way to do this in htaccess file instead? Or is code in the header.php file the best option?

https://www.i-hled.co.uk/product-category/light-engines/led-count-one/page/2/ https://www.i-hled.co.uk/product-category/light-engines/led-count-one/page/3/ etc

Will not be indexed, but https://www.i-hled.co.uk/product-category/light-engines/led-count-one/one-led/page/2/ https://www.i-hled.co.uk/product-category/light-engines/led-count-one/one-led/page/3/ etc

Will be indexed

Ruth
  • 71
  • 7

1 Answers1

1

I used All in One SEO API to fix this as follows

 add_filter( 'aioseop_robots_meta', 'change_robots_meta_value' );

 function change_robots_meta_value( $robots_meta_value ) {
 if( is_product_category( 'PYO' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
if( is_product_category( 'Light Engines' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
    if( is_product_category( 'LED Count' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
        if( is_product_category( 'Micromoles' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
            if( is_product_category( 'Size' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
                if( is_product_category( 'Wavelength' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
                    if( is_product_category( 'Thermal' ) && is_paged() ) {
      $robots_meta_value = 'noindex,nofollow';
 }
 return $robots_meta_value;
}
Ruth
  • 71
  • 7