Next and Prev Canonical tags on blog

#28726
  • Resolved Will T.
    Rank Math free

    Hi There,

    We are trying to get our <link rel=canonical href=https://urlhere.com/blog/ > to display <link
    rel=canonical href=https://berkshirecbd.com/blog/2/ > on the paginated pages. We would also like to add the rel prev and next canonical tags as well. For some reason it’s not showing. We were able to implement this on the Author pages with ease, but not the blog page for some reason. Any insight?

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    You can easily customize the canonical URL returned on the paginated pages by using the following filter on your theme’s functions.php file:

    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	return $canonical;
    });

    Looking forward to helping you. Thank you.

    Hi There,

    Should something like this work? For some reason it’s not showing on our pages:

    /**
    * Allow changing of the canonical URL.
    *
    * @param string $canonical The canonical URL.
    */
    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {

    if ( !is_front_page() && is_home() ) {

    global $paged;

    if ( get_previous_posts_link() ) { ?>
    <link rel=”prev” href=”<?php echo get_pagenum_link( $paged – 1 ); ?>” /><?php
    }

    if ( get_next_posts_link() ) { ?>
    <link rel=”next” href=”<?php echo get_pagenum_link( $paged +1 ); ?>” /><?php
    }

    }

    return $canonical;
    });

    Thank you!

    Further look, this seems to be an elementor page element with pagination. Any thoughts on that? Thank you!

    Todd
    Rank Math free

    Hi Will,

    Please note that Google dropped support for rel=”next” and prev tags quite a while back:

    https://searchengineland.com/google-no-longer-supports-relnext-prev-314319

    The best option to do for paginated pages is to mark them as noindex.

    Head over to WordPress Dashboard > Rank Math > Titles & Meta > Misc. Pages.`

    Scroll down a bit and you will see the Noindex Paginated Pages option.

    If you still wish to do it like you mentioned, please wait for someone from our dev. team to get back to 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 4 replies - 1 through 4 (of 4 total)

The ticket ‘Next and Prev Canonical tags on blog’ is closed to new replies.