Skip to content

Instantly share code, notes, and snippets.

@RiodeJaneiroo
Last active October 1, 2019 10:11
Show Gist options
  • Save RiodeJaneiroo/c113268446c626a4b4a4a7f39569c548 to your computer and use it in GitHub Desktop.
Save RiodeJaneiroo/c113268446c626a4b4a4a7f39569c548 to your computer and use it in GitHub Desktop.
[Wordpress Yoast remove page in canonical] #seo #yoasy #wordpress
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_home_url_slash' );
function yoast_seo_canonical_change_home_url_slash( $canonical_url ) {
$re = '/\/page\/\d+\//m';
$str = $canonical_url;
$subst = '/';
$result = preg_replace($re, $subst, $str);
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment