Created
May 19, 2021 10:35
-
-
Save javi-g/d0a0f1f33cc7d009be19e1ad903f8868 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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