Created
November 13, 2013 13:36
-
-
Save aahan/7449233 to your computer and use it in GitHub Desktop.
WordPress SEO by Yoast filters
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
<?php | |
// Remove Canonical Link Added By Yoast WordPress SEO Plugin | |
function at_remove_dup_canonical_link() { | |
return false; | |
} | |
add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' ); | |
function wpseo_attachment_canonical_parent( $canonical ) { | |
if ( is_attachment() ) { | |
global $post; | |
$attachment = get_post( $post->ID ); | |
$parent_post_id = $attachment->post_parent; | |
$canonical = get_permalink( $parent_post_id ); | |
} | |
return $canonical; | |
} | |
add_filter( 'wpseo_canonical', 'wpseo_attachment_canonical_parent' ); | |
function wpseo_canonical_exclude( $canonical ) { | |
global $post; | |
if ( $post->ID == 4350) { | |
$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