Support » Fixing WordPress » Wrong canonical in wp_head – how to remove in WP 4.5.2

  • Kristof



    Is there a way to remove WordPress’ (4.5.2) own rel_canonical link in head section of HTML?

    So far I tried to add
    <?php remove_action('wp_head', 'rel_canonical'); ?>
    to my functions.php of my theme, which doesn’t do anything.
    I also tried it in my themefiles.php before and after calling wp_head();
    Did the name of the action change? Is it not a action? How can I figure that out? I don’t get further here.

    I also tried

    /* remove canonical
    function at_remove_dup_canonical_link() {
    return false;
    add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' );

    like above – no effekt, the canonical is still showing wrong.

    my other remove_actions work fine.

    I run WP 4.5.2 as a multisite, subdirectory network.

    It shows wrong, because it shows just the URL of the request. So it shows https://whatver or http://whatever – it should always be http://whatever in this case. I can do that whith All in One SEO (AiOSEO) which I like to use. But in addition to the correct canonical from AiOSEO I have a second and wrong canonical of WordPress as well.


Viewing 2 replies - 1 through 2 (of 2 total)
  • Kristof



    I tried <?php remove_action('wp_head', 'rel_canonical'); ?> with WordPress 4.3.4 and it works.

    In addition I found the /wp-includes/default-filters.php to look up all the actions and filters and added the followin to my 4.5.2 setup

    remove_action ('embed_head', 'rel_canonical');
    remove_action ('template_redirect', 'redirect_canonical');
    remove_action ('template_redirect', 'wp_redirect_admin_locations', 12);
    remove_filter ('option_blog_charset', '_canonical_charset');

    still the wrong canonical is showing – I guess now I am really out of ideas.




    I found a compromis.

    Instead of focusing how to figure out the canonical issue, i took it for granted an redirect all the requets for the frontend to http. this way i can still use my private ssl for the backend.

    I hope someone else can use it.

    If however someone knows why I couldn’t disable WordPress’ canonical, please let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wrong canonical in wp_head – how to remove in WP 4.5.2’ is closed to new replies.