Managing SEO for WordPress sites often raises the question of whether pagination pages should be indexed. By default, Yoast SEO used to include a setting to mark paginated pages with noindex, follow, but this option was later removed in line with Google’s updated recommendations.
However, not all site owners agree with this approach. If you run a blog or a WooCommerce store, you probably don’t want Google to waste its crawl budget on the 15th or 42nd page of a category archive. Instead, you’d prefer Google to focus on the main category page and your individual posts or products.
That’s where a simple code snippet comes in handy. By adding the following function to your functions.php, you can restore the old Yoast SEO behavior and ensure that only the first category page remains indexable, while all subsequent pagination pages get noindex, follow:
/* Yoast SEO - add noindex, follow for paginated pages */
function filter_wpseo_robots( $robotsstr ) {
if ( is_paged() ) {
return 'noindex, follow';
}
return $robotsstr;
}
add_filter( 'wpseo_robots', 'filter_wpseo_robots' );
Leave a Reply