noindex paginated post types & rel prev/next

#219754
  • Resolved Digital Marketing
    Rank Math business

    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/&#8221; />
    <link rel=”prev” href=”https://dev.domain.com/news/page/4/&#8221; />
    <link rel=”next” href=”https://dev.domain.com/news/page/6/&#8221; />

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math today.

    We only add the canonical to pages that are set to index. If you have enabled the option to noindex the paginated pages, the canonical won’t show up on those pages even if you try to set it manually via the filter.

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    Thank you Uzair,

    I’ve already tried the filter but it doesn’t work.
    Could you tell me how to add this feature via filter because the code I entered is overwritten by the options via the web.

    Thank you.

    Hello,

    As my colleague mentioned previously if you have those pages as noindex the filter will not work no matter what.

    The filter only runs if those pages are set to be indexed.

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘noindex paginated post types & rel prev/next’ is closed to new replies.