Canonical tag for add-to-cart

#636282
  • Resolved Hodo
    Rank Math free

    Hello there.
    The code seems to have been resolved in the “wishlist”? ticket #623977
    Is there one for “add-to-cart”?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    I have modified the code a bit to include add-to-cart query URLs. Please refer to this code below:

    add_filter('rank_math/frontend/robots', function ($robots) {
    	$url = home_url($_SERVER['REQUEST_URI']);
    	if ((strpos($url, '?add_to_wishlist=') !== false) || (strpos($url, '?add-to-cart=') !== false)) {
    		$robots["index"] = 'noindex';
    		$robots["follow"] = 'nofollow';
    	}
    	return $robots;
    });

    Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.

    Hodo
    Rank Math free

    Hello there.
    Thank you for help.

    Hello,

    Glad that helped.

    If you have any other concerns, please don’t hesitate to contact us anytime to assist you further.

    Looking forward to helping you.

    Thank you.

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

The ticket ‘Canonical tag for add-to-cart’ is closed to new replies.