Setting correct pagination canonicals

#841265
  • Resolved Waldhirsch
    Rank Math free

    Hello,

    My website has pagination which works like this:

    [moved to sensitive data section]

    I have already tried various code snippets to set my canonical URL to the first page, but nothing has worked so far. These are the snippets I’ve tried:

    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;
    });

    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
    $url = ‘https://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];
    if(strpos($url,’shop’) !== false){
    return $url;
    }

    return $canonical;
    });

    What else can I do?

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

You must be logged in to reply to this ticket.