Disable link rel='canonical' at theme level (5 posts)

  1. SEO Dave
    Posted 5 years ago #

    Running a modified version of the plugin SEO Super Comments which creates spiderable pages from comments.

    Since link rel='canonical' was added to WordPress core (I used to add it at theme level) the single comment pages created by the plugin like


    Now have a rel='canonical' tag within the head pointing to the single blog post the comment is related to. This means Google won't keep these pages indexed making the plugin useless.

    I use a copy of single.php (renamed and edited) to generate the single comment pages, ideal solution would be to not use the

    add_action( 'wp_head', 'rel_canonical' );
    from wp-includes/default-filters.php

    For just that template page.

    If that's not realistic, completely disable the filter at theme level and I'll just keeping using the code I used to use to add rel='canonical' to various pages.

    The theme I use is also sold, so although I could easily remove the filter from wp-includes/default-filters.php I need it at theme level as I'm working on a new release of the theme with support for the SEO Super Comments plugin.


  2. SEO Dave
    Posted 5 years ago #

    Solved the problem, pretty easy as well.


    <?php wp_head(); ?>

    From the extra single.php template page.


  3. esmi
    Forum Moderator
    Posted 5 years ago #

    Won't that cause problems for other plugins that rely on wp_head?

  4. SEO Dave
    Posted 5 years ago #

    Hi Esmi,

    Since this is a second copy of single.php (I named it single2.php) and all it does is create pages like http://www.45-year-old-millionaire.co.uk/claiming-working-tax-credit-instead-of-job-seekers-allowance-income-support.html/comment-page-1?cid=7006 I don't need too many plugins to work with those pages.

    Remember this is just about getting the plugin SEO Super Comments to work correctly which generates individual pages from comments.

    On the example page above you'll note the Tweetme link (from a plugin) isn't working correctly, doesn't work on these pages with <?php wp_head(); ?> included either (need to find a fix to block that plugin on those pages). Had a similar problem on another site with a poll plugin that called javascript via the header, had to add it manually so a poll widget would work on these pages.

    You expect a few issues like these when you use plugins like the SEO Super Comments that's doing something WordPress is not designed for (comments aren't supposed to have their own pages).

    I did realise later I could use something like:

    remove_action ('wp_head', 'rel_canonical');

    Added to the functions.php file to block this filter completely and rely on the code I used to use to generate the canonical links. Currently testing with this option :-)


  5. erick_paper
    Posted 5 years ago #

    Actually remove_action in functions.php does nothing.

    Any other suggestions? I'd like to get rid of the "rel" links created by wp_head.


Topic Closed

This topic has been closed to new replies.

About this Topic