I'm trying to remove the canonical link reference from my page headers and I'm using the following code in my functions.php:

remove_action('wp_head', 'rel_canonical');

However, when I test the return value of remove_action it's value is FALSE and I notice that the canonical link reference is still rendered in the head of my pages.

I've tried wrapping the remove_action in an init but I get the same result:

function my_init()
   remove_action('wp_head', 'rel_canonical');

add_action('init', 'my_init');

How do I remove the canonical link reference from my page headers?

  • Where is this action being set? Nov 12, 2012 at 2:17
  • You mean by Wordpress? In wp-includes/default-filters.php line 209
    – Luke
    Nov 12, 2012 at 4:20
  • 1
    Works for me - are you using any plugins? Nov 12, 2012 at 10:02
  • Which one is working for you? With or without the init?
    – Luke
    Nov 12, 2012 at 19:09

1 Answer 1


Locate the original add_action call and make sure that your remove_action call exactly mimics it including the $priority and $accepted_args parameters.

  • Already checked that. It's added in wp-includes/default-filters.php line 209. No priorities or other parameters are specified.
    – Luke
    Nov 12, 2012 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.