If you’ve upgraded to the 2.9 track of WordPress (and if not, why not) you may have noticed that the new built-in canonical URL function is a bit hinkey.
Thankfully most of the common SEO plugins for WP already handle canonical URLs quite nicely, so the best thing to do for now is to disable the built-in URL generation.
You can do this quite simply by adding the following to your theme’s functions.php:
# Remove WordPress' canonical links
remove_action('wp_head', 'rel_canonical');
Simples!
Thank you for this hook! I was hoping there was an filter/hook and didn’t have to hack core for this. This is especially handy when you are using WP as a CMS or web app, and you are using custom queries to deep link into certain content, and you want the canonical url to be intentionally specified to provide contextual awareness to the deep linked content via your own custom wp_head hook.
Thanks for this.
I couldn’t remember what we did and on which client’s site we did it on so this helped us greatly!
[...] your WordPress not to generate canonical link element in the header? One way you can do it is by modifying your theme’s functions.php file – this method however did not work on my WordPress 3.0 [...]