How to make filter URLs self referential?

#562682
  • Resolved Remco Harmsen
    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 give the filter URLs self referential canonical tag?
    Right now they point to the main category page.

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

    Many thanks in advance,

    Remco

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with setting a custom canonical for your product category pages filtered by brand.

    If I understand correctly you would like to have canonical="https://yoursite.com/product-category/toy-car/?filter-brand=bmw

    To do this you will have to customize our filter to modify canonical URLs:

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

    You may refer to this guide for how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Please let us know if you have questions.

    Great, thanks 🙂

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘How to make filter URLs self referential?’ is closed to new replies.