Remove Canonical URL on a Page

Need help with this?
Purchase All in One SEO Pack Pro to get dedicated support from us.

Buy Now

If you need to disable All in One SEO Pack’s canonical URL functionality on a particular page, you can use the aioseop_canonical_url filter hook.

This filter hook accepts one parameter, which is the original URL. Use some sort of logic to determine the conditions, then you can either return a different URL, or simply return false to remove the canonical URL under those conditions.

add_filter('aioseop_canonical_url','change_canonical_url', 10, 1);

function change_canonical_url( $url ){

// Use whatever logic you like here. In this example, we're returning a different canonical URL for post ID=2.

global $post;
 if( $post->ID === 2){
 return 'http://canonicalurl.com'; // Return canonical URL for post #2.
 }
 return $url;
 }

add_filter('aioseop_canonical_url','remove_canonical_url', 10, 1);

function remove_canonical_url( $url ){

// Use whatever logic you like here. In this example, we're removing the canonical URL for post ID=2.

global $post;
 if( $post->ID === 2){
 return false; // Remove the canonical URL for post #2.
 }
 return $url;
}
[i]
[i]
Skip to toolbar