• Resolved reminaizer

    (@reminaizer)


    Hey,
    I am trying to set self-canonical on paginated blog post pages. How can I do that with RankMath?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @reminaizer,

    Thank you for contacting the support.

    Rank Math adds a self-referencing canonical URL by default, meaning if your paginated page is /page/2/, the canonical URL should be the same.

    If it’s not working for you, then you may try adding the following filter to add self-referencing canonical URLs for your paginated blog pages:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $current_url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(false === strpos($current_url, '/page/') || is_single()) return $canonical; $canonical = strtok($current_url, '?'); return $canonical; });

    Here is how you can add filters/hooks to your WordPress site:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thread Starter reminaizer

    (@reminaizer)

    Thank you very much. Works like a charm. 🙂

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @reminaizer

    Glad that helped.

    If it isn’t too much to ask for – would you mind leaving us a review here?
    https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post

    It only takes a couple of minutes but helps us tremendously.

    It would mean so much to us and would go a really long way.

    Thank you.​​

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to set a self-canonical reference to pagination pages’ is closed to new replies.