Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    WordPress and Google Analytics external nofollow problem in comment links

    13th February 2009

    Since some WP release, the comment author’s link in comments is broken – it has ‘ external nofollow’ attached straight to the href attribute (which breaks the link).

    I assume that the problem is caused by Google Analytics, namely the “track outgoing clicks” feature (as recalled, might be inaccurate feature name). “Track outgoing links” adds some JavaScript code to all outgoing links, and that script has tick characters like this one ‘ which, incidentally, are also used for delimiting the values of comment anchor tags.

    To fix:

    1. locate file wp-includes/comment-template.php
    2. in that file, find the get_comment_author_link function (lines 140-150 in WP 2.7.1)
    3. replace the line
      1. $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

      with

      1. $return = '<a href="'.$url.'" rel="external nofollow" class="url">'.$author.'</a>';

    This helped me and might help you.

    Share

    2 Responses to “WordPress and Google Analytics external nofollow problem in comment links”

    1. Chad Says:

      I disabled the GoogleAnalytics.php plugin and my links started working again normally.

    2. Bogdan Says:

      My “Google Analytics 0.68″ WP plugin is inactive – I think I’m using HeadSpace for this and other purposes. So it might have the same code for rewriting links :)

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>