How to (canonical) filter URLs and URL pagination point to main category page?

#640521
  • Resolved Sendoravn
    Rank Math free

    Hello πŸ™‚

    I am working on a woocommerce website and love the Rank Math options for this.
    There is one problem left and I would love your help:

    How can I make (canonical) filter URLs and URL pagination point to main product category page?
    Right now they didn’t point to anything, while the main product category page has been canonicalized to itself.

    If you could make this happen, that would be great.

    Many thanks in advance,

    Sendora

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    We’ve checked the filtered URL you have shared in the sensitive data section, but the canonical is already pointing to the main URL. You can refer to the screenshot attached there as well.

    For the paginated URLs, you may add this code to set their canonical to the first page:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        global $wp;
        $current_slug = home_url( $wp->request );
    
        if ( is_paged()) {
            $canonical = $current_slug . '/';
        }
    
        return $canonical;
    });

    And here’s a guide on how you can add a filter to your website:
    https://rankmath.com/kb/filters-hooks-api-developer/

    Hope that helps.

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

The ticket ‘How to (canonical) filter URLs and URL pagination point to main category page?’ is closed to new replies.