8

wordpress core automatically generates canonical tag in HEAD section:

<link rel="canonical" href="http://blabla.com" />

how to disable/remove that?

12

found solution: before wp_head() command, insert:

remove_action('wp_head', 'rel_canonical');

p.s. if generator meta tag is being added from elsewhere (i.e. from theme or plugin, rather than wp-core) and was priority other than 10, then you might need to put the exact priority, as is was given from that theme/plugin:

i.e. remove_action('wp_head', 'rel_canonical', 47);
7
  • Please explain why this works. – s_ha_dum Mar 7 '14 at 19:18
  • This didn't work for me, can you please help – Hari Swaminathan Jan 24 '17 at 10:39
  • @HariSwaminathan: many plugins may also generate rel=canonical links. Try turning plugins off (or looking at their code) to see if that helps. – Denise Draper Feb 21 '17 at 20:33
  • 1
    @squarecandy thanks, but it was good you also mentioned, why removing shortlink is good for site or seo? – T.Todua Mar 27 '18 at 7:49
  • 1
    It has little or no effect on SEO, as most wordpress setups have the /?p=1234 set to redirect to the regular URL. It's just a personal thing - I don't like the look of the short urls the way WordPress automatically does them, and sometimes they are not even shorter than the original like /about/ vs ?p=13243 so I would prefer not to broadcast that to the world as the official shortlink for the page. – squarecandy Mar 27 '18 at 15:31

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