Support » Themes and Templates » Disable link rel=’canonical’ at theme level

  • 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.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Solved the problem, pretty easy as well.


    <?php wp_head(); ?>

    From the extra single.php template page.




    Forum Moderator

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

    Hi Esmi,

    Since this is a second copy of single.php (I named it single2.php) and all it does is create pages like 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 🙂


    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.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable link rel=’canonical’ at theme level’ is closed to new replies.