• Kristof

    (@kh-webmaster)


    Hi,

    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 https://whatever – it should always be https://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.

    Cheers

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

    (@kh-webmaster)

    Update:

    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.

    cheers

    Thread Starter Kristof

    (@kh-webmaster)

    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.

    https://blackhillswebworks.com/2013/10/30/redirect-wordpress-front-end-https-urls-to-http-without-a-plugin/

    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.