Changing canonical URL for pagination

#886021
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    In this case, you can use the following filter to set the self-referencing canonical of the paginated pages:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
             if( is_paged() ) {
                      $current_url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];  
                      return $current_url; 
             }
             return $canonical;
    });

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

    That did not change, see this paginated page for reference:
    https://doftrum.se/doftljus/?sf_paged=3

    Hello,

    It seems like WordPress is not able to recognize the pages as paginated. In this case, please try to use the following filter and see if that works for you:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        $current_url= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        $canonical = $current_url;
        return $canonical;
    });
    

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

    Thank you.

    I’m also having this same issue. I’ve tried both those scripts above and neither worked?

    Hello @lukeharris,

    Please open a ticket for your particular use-case as we might need to ask further questions and working WP credentials to fully debug the issue.

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

The ticket ‘Changing canonical URL for pagination’ is closed to new replies.