Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save javi-g/d0a0f1f33cc7d009be19e1ad903f8868 to your computer and use it in GitHub Desktop.
Save javi-g/d0a0f1f33cc7d009be19e1ad903f8868 to your computer and use it in GitHub Desktop.
// Tras rewrite en WooCommerce, Yoast seguía devolviendo canonicals antiguos
// Código para prevenirlo (usadlo con cuidado y comprobar los canonicals posteriormente)
function usm_filter_yoastcanonical( $canonical ) {
if (is_product()) { // sólo alteramos el canonical de los productos, no el resto
$canonical = get_permalink();
}
return $canonical;
}
add_filter( 'wpseo_canonical', 'usm_filter_yoastcanonical' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment