Skip to content

Instantly share code, notes, and snippets.

@yxod
Created June 7, 2023 12:53
Show Gist options
  • Save yxod/c8eb58e9d0ee4b5a88db008dc92640f2 to your computer and use it in GitHub Desktop.
Save yxod/c8eb58e9d0ee4b5a88db008dc92640f2 to your computer and use it in GitHub Desktop.
add canonical paged category
// add canonical category paged
function yoast_seo_canonical_change_woocom_shop($canonical)
{
if (is_paged() && is_category()) {
$category = get_queried_object();
$category_link = get_category_link($category);
$canonical = esc_url($category_link);
}
return $canonical;
}
add_filter('wpseo_canonical', 'yoast_seo_canonical_change_woocom_shop', 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment