Changing author’s comment links

Posted by Lyndi

I received a mail from a friend asking the following:

…I read somewhere that when you reply to comments on your own site that it is not a good idea to have your name linked back to your own blog…

This one really got me thinking. I am not really into SEO and this is something that would normally not worry me. I then went and had a look at the comments on this blog. By default WordPress links the comment author’s name to the url the commenter provided. In the case of the author of the article the name on the comment is linked to the main page of the blog.

If this now has an adverse effect on SEO I do not know. The problem is just what purpose does a link pointing to your own home page actually have.

In WordPress 2.7 one calls the comments with the function wp_list_comments. There are no arguments that one can use to change the settings of your comments. This is what I thought until I read this article.

It is possible to change the settings for your comments even in version 2.7. I thought that it would be handy to have the article author’s comment links to point to a list of that author’s articles on the blog. This would be very handy especially on a multi-author blog. The other thing I wanted to do was to change the size of the avatar shown on the comments. Until now I have been making this last change in the stylesheet.

The mentioned article showed me how to do both these things. Firstly I changed the code in comments.php:

<?php if ( have_comments() ) : ?>
	<?php if ( ! empty($comments_by_type['comment']) ) : ?>
		<h4 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h4>
		<ol class="commentlist">
			<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
		</ol>
	<?php endif; ?>
	<?php if ( ! empty($comments_by_type['pings']) ) : ?>
		<h4 id="pings">Trackbacks/Pingbacks</h4>
		<ol class="commentlist">
			<?php wp_list_comments('type=pings&callback=mytheme_comment'); ?>
		</ol>
	<?php endif; ?>
 <?php else : ?>

The red bits is the code that I added to the existing code. You can now, from this code, also see how I separate the comments from the trackbacks on this blog.

I now had to add some code to functions.php:

function mytheme_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
		<?php if (6 == $comment->user_id) : ?>
         	<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), the_author_posts_link('namefl')) ?>
      	<?php else : ?>
			<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
		<?php endif; ?>
	  </div>
      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.') ?></em>
         <br />
      <?php endif; ?>

      <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>

      <?php comment_text() ?>

      <div class="reply">
         <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </div>
     </div>
<?php
        }
This entire block of code has to be added to your functions.php. This code comes straight from the WordPress Codex article linked to above. I simply added a loop to check if a comment is made by the article author or not. This part I have marked in red. The 6 used in the loop I added is my own author id on this blog. You will see that I also changed the avatar size to 48.

You can now change the author’s link to point to wherever you want it to. You could in fact remove the link from the article author’s comments completely.

Hey presto, it worked. Don’t you just love it when things actually work.

I hope you can find a use for this somewhere along the line. My thanks to Mik for the original query which led to this little article.

Till next time.

If you have found this article useful, please consider subscribing to the RSS feed. You could do this via your favourite feed reader or via Email.

Many of the WordPress hacks, tips and bits of advice provided on this blog, include code snippets. If you are making use of any code provided here kindly take note that I cannot be held responsible for anything that might go wrong on your blog because of the new code. Before making any changes to your files please ensure that these files have been adequately backed-up.

If you are passionate about WordPress and you are interested in writing a guest post or even collaborating on Nice2All, please contact me.

CMF Ads - Low cost, no-nonsense advertising

Similar Posts

Post Title: Changing author’s comment links
Author: Lyndi
Posted: 14th January 2009
Filed As: WordPress
Tags:
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

26 Opinions have been expressed on “Changing author’s comment links”. What is your opinion?
  1. Squeaky commented:

    Looks interesting and will be adding this to my blog. Not sure about its SEO value, but will look at that as well.

  2. Squeaky commented:

    My understanding is that any internal linking would have some SEO value. Have you read up on deep linking? Internal linking/deep linking is said to help obtain a site authority status.

    • Lyndi commented:

      All sounds very SEO’ish to me. The only thing I am glad about is that now I get to decide where my own links on the comments point to. One could even make these links ‘nofollow’ which will really remove the search bots from the equation.

  3. Squeaky commented:

    I will be asking my coder for his thoughts on the SEO value and let you know what he has to say about it.

  4. Squeaky commented:

    Lyndi,

    I My coder said, I don’t advise on installing this one. He doesn’t think that it offers enough to add to the blog at this time. I sent you a email copy of what he said.

    • Lyndi commented:

      Everyone has the right to their own opinions. By the way, the purpose of this post was not to get everyone to change their links in the comments. The purpose was to answer the original query and show that it is possible to override the new function used in WordPress 2.7.

      • Squeaky commented:

        Having opinions is what makes each of us different. I also realize that you helped someone by answering their question and gave them a solution. I was looking at it as a potential item to add for SEO reasons, but appears my coder doesn’t advice me to do so.
        No problem here and not meant to create any problems on your end.

        • Lyndi commented:

          As stated in the article I feel that this can have no SEO effect at all, or at least I do not think so. I personally have also not implemented this on the comments, I have only implemented it on the author’s link on every article on the main page.

  5. Mik commented:

    Wow Lyndi you went all out on this in answer to my query. I wish I could locate what I originally read that prompted the thought.

    Least we now have an option thanks to the the code changes. I noticed some of the big make money bloggers leave the comment link in, so I guess it is a matter of choice.

    We are all a learnin’

  6. Read 2 Know commented:

    I guess Mik got the answer for his query. I have a question out of this answer. How does it affect SEO? Any SEO specialist here??

    • Lyndi commented:

      Squeaky is a SEO expert but even he says the jury is still out on this one. All those links pointing at your home page – I don’t know.

    • Squeaky commented:

      Internal linking as a rule does help with SEO and building an authority site. But, since these links aren’t keyword rich they probably wouldn’t have much SEO value, if at all.
      Since this is the first time that I have seen this type of link used with WordPress, I can’t actually back up anything that I am saying because I have no hands on experience using this technique.
      The only way to really know, is to try it and see what happens. But I would try it on a test site which isn’t your main site, just in case things go sour.

      I don’t consider myself an SEO specialist, but I have been doing it off/on for many years. From time to time, I have to check with my mentors and sometimes they don’t agree with each other.

      • Lyndi commented:

        I do not know if this is good or bad news. I really cannot see anything wrong with linking to your own home page. I do see one problem though. We all want the bots to crawl deeper into our sites, these links (the home page links) will keep throwing them back to the beginning. I am speculating, so maybe I am completely off track here.

  7. Mik commented:

    Some of the big Pro blogging sites seem to have the comment link directed back to their home page. So be interesting to find out opinions on this.

    • Squeaky commented:

      I am thinking that they do this for gaining authority status by using this to gain more internal linking. Just my opinion.

  8. Nihar commented:

    Nice post. I don’t think SEO will get effected for self linking due to author comments link.

    This post will help me in some other way.i.e., right now comments and trackbacks(pings) are mixed in my blog. i will use your snippet of code to separate it.

    Thanks.

    • Lyndi commented:

      I knew someone will pick up that I actually showed you how to do this. On that portion you now simply have to leave out the red bits I added to the code. Remember this code will only work for version 2.7.

  9. Squeaky commented:

    I am thinking it would be nice if we clicked on our links in the comments section of the articles and it would take you to a about page or bio page about me, that might be more useful.

    what are your thoughts?

    • Lyndi commented:

      That would be great, especially if you’ve got a multi-author blog. On a single-author blog you could end up with the same situation you have by default, a lot of links pointing at the same page. This could be something to think about.

      • Squeaky commented:

        On a multi-author blog if their link would point to their about page or author page, it would be a nice way to reward them.

  10. devolute commented:

    This proved pretty healthy as I’m now styling my new WP theme. The WP codex is a little lacking in this area. Thanks!