Moving the number of comments to the top of the post in TwentyTen

In the main blog view, the TwentyTen theme places the number of comments that a post has received after the post.

Moving this to the top of the post requires a modification to the part of the theme called “the loop”.  This is the code that WordPress executes for every post that is shown in that view.

In TwentyTen, this code is in a file called loop.php.  Here’s how to modify it:

You can access the loop.php by logging into WordPress and then selecting Appearance > Editor and then loop.php.

Then look for the following code:

<span class=”comments-link”>&nbsp;&nbsp;<?php comments_popup_link( __( ‘Leave a comment’, ‘twentyten’ ), __( ‘1 Comment’, ‘twentyten’ ), __( ‘% Comments’, ‘twentyten’ ) ); ?></span>

It’s located in an area called “entry-utility”.

The code to move(Click on the image to enlarge)

Cut out this text and insert it in the “entry-meta” area after this:

<?php twentyten_posted_on(); ?>

Where to move it toYou might like to add some square brackets as well to separate it from the post date.  Like this:

<span>&nbsp;&nbsp;[<?php comments_popup_link( __( ‘Leave a comment’, ‘twentyten’ ), __( ‘1 Comment’, ‘twentyten’ ), __( ‘% Comments’, ‘twentyten’ ) ); ?>]</span>

Now click on “Update file” and re-load your blog’s main page.

About Graham Tappenden

Graham Tappenden is a blogger from Germany. He has written code for WordPress themes since 2006 and been creating websites since 1994.
This entry was posted in TwentyTen and tagged , , , . Bookmark the permalink.