Forums

Comment author is not 'nofollow' - why? (4 posts)

  1. enigma2k
    Member
    Posted 2 years ago #

    WordPress automatically makes any link nofollow except the comment author. I have checked the comment-template.php but it seems to be fine:

    function get_comment_author_link() {
    	/** @todo Only call these functions when they are needed. Include in if... else blocks */
    	$url    = get_comment_author_url();
    	$author = get_comment_author();
    
    	if ( empty( $url ) || 'http://' == $url )
    		$return = $author;
    	else
    		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
    	return apply_filters('get_comment_author_link', $return);
    }

    Is there anywhere else I could look?

  2. enigma2k
    Member
    Posted 2 years ago #

    I have found the relevant part of the code, it was under themes in my functions.php. The problem is, however, I don't know where to add the rel='external nofollow'

    <?php
    
        if (get_comment_author_url()):
    
          $authorlink='<span class="with-tooltip"><a id="commentauthor-'.get_comment_ID().'" href="'.get_comment_author_url().'">'.get_comment_author().'</a></span>';
    
                else:
    
            $authorlink='<b id="commentauthor-'.get_comment_ID().'">'.get_comment_author().'</b>';
    
           endif;
    
             printf(__('%s by %s on %s', 'arclite'), '<a href="#comment-'.get_comment_ID().'">#'.++$commentcount.'</a>', $authorlink, get_comment_time(get_option('date_format')).' - '.get_comment_time(get_option('time_format')));
    
                                        ?>

    I have tried putting it right after href="'.get_comment_author_url().'" but this crashes wordpress.
    $authorlink='<span class="with-tooltip"><a id="commentauthor-'.get_comment_ID().'" href="'.get_comment_author_url().'" rel='external nofollow'>'.get_comment_author().'</a></span>';

    Has anybody a solution to this?

  3. enigma2k
    Member
    Posted 2 years ago #

    no one? I think this is actually easy if you know about php and wordpress. :)

  4. enigma2k
    Member
    Posted 2 years ago #

    Ok I have managed it myself, I had to write rel="external nofollow" instead of rel='external nofollow'.
    Anybody knows why this is so?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.