Last active
August 29, 2015 14:14
-
-
Save Xyborg/b55826218ac8ff5bf01b to your computer and use it in GitHub Desktop.
SEO by Yoast: Exclude URLs from canonical
This file contains 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
/* Add this function to the functions.php in your theme folder */ | |
/* to exclude certain posts from url canonicalization of SEO by Yoast plugin */ | |
function wpseo_canonical_exclude( $canonical ) { | |
global $post; | |
if ( get_post_type( get_the_ID() ) == "name_your_post_type") { | |
//if ( $post->ID == 7777) { | |
$canonical = false; | |
} | |
return $canonical; | |
} | |
add_filter( 'wpseo_canonical', 'wpseo_canonical_exclude' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment