Duplicate canonical for product and category

#203046
  • Resolved Toma
    Rank Math free

    Hello πŸ™‚ ,

    I would like to remove the canonical rel code for the product and product category (collections) pages. I have a plugin that does this instead of Rank Math but I can’t remove the Rank Math one.

    Thanks in advance.

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

    Hello,

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

    To remove the canonical tag from the product and product category pages, you need to put the below code inside your themes function.php file.

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

    I hope that helps. Thank you, and please don’t hesitate to contact us anytime if you need further assistance.

    Toma
    Rank Math free

    Thank you : It worked well !

    Ankit
    Rank Math business

    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 ‘Duplicate canonical for product and category’ is closed to new replies.