Created
May 10, 2021 18:44
-
-
Save xlawok/5d5bcb43e41ee48a704579e1cade1a23 to your computer and use it in GitHub Desktop.
Woocommerce paged category and tags canonical
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(is_paged()&&is_product_category()) { | |
$thisCat = get_query_var('product_cat'); | |
$category_link = get_term_link($thisCat, 'product_cat'); | |
echo '<link rel="canonical" href="' . $category_link . '" />'; | |
} | |
if(is_paged()&&is_product_tag()) { | |
$thisTag = get_query_var('product_tag'); | |
$tag_link = get_term_link($thisTag, 'product_tag'); | |
echo '<link rel="canonical" href="' . $tag_link . '" />'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment