-
Hi my SEO Agency needs a particular configuration inside my post and customs post types.
I need inside posts paginated this meta in this URL https://dev.domain.com/news/page/5/:<meta name=”robots” content=”follow, noindex”/>
<link rel=”canonical” href=”https://dev.domain.com/news/” />
<link rel=”prev” href=”https://dev.domain.com/news/page/4/” />
<link rel=”next” href=”https://dev.domain.com/news/page/6/” />But when i select noindex paginated page disappear also canonical & rel/prev meta.
I found this code for noindex but don’t work:
add_filter(‘rank_math/frontend/robots’, function ($robots) {
global $wp_query;
$paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1;var_dump($paged);
if ($paged > 1 && is_post_type_archive(‘custom_post’,’post’) ) {
$robots[‘index’] = “noindex”;
$robots[‘follow’] = “follow”;
return $robots;
} else {
return $robots;
}
});and this code for add canonical URL to first archive page:
add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
if ( $paged > 1 && is_post_type_archive(‘custom_post’,’post’) ) {
return get_main_page_url();
}
return $canonical;
});Thank you for your support
Maurizio
The ticket ‘noindex paginated post types & rel prev/next’ is closed to new replies.