Skip to content

Instantly share code, notes, and snippets.

@kbcarte
Created April 3, 2023 15:42
Show Gist options
  • Save kbcarte/32e1de04e0824390b268606f376ef5c6 to your computer and use it in GitHub Desktop.
Save kbcarte/32e1de04e0824390b268606f376ef5c6 to your computer and use it in GitHub Desktop.
Remove the trailing slash from the canonical meta link form Yoast SEO
<?php
/* Place in functions.php */
function prefix_filter_canonical_example( $canonical ) {
if ( substr( $canonical, -1 ) == "/" ) {
return substr($canonical, 0, -1);
}
return $canonical;
}
add_filter( 'wpseo_canonical', 'prefix_filter_canonical_example' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment