Yoast: Building Page.ly Part4: Scalable and Fast Managed WordPress Hosting | Page.ly Blog http://t.co/ba32Hemn ReTweet Reply

Implementing in WordPress 2.7

The TweetBacks WordPress plugin imports tweets as comments, storing them in between your other comments in the database. When it does that though, it gives them a specific type "tweetback". Because of this, you can separate the tweetbacks from normal comments and pingbacks/trackbacks.

To do this on WordPress 2.7, follow the following tutorial:

  1. First, let's have a look at the default comment loop:
    <?php if ( have_comments() ) : ?>
      <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
      <ol class="commentlist">
      <?php wp_list_comments(); ?>
      </ol>
      <div class="navigation">
        <div class="alignleft"><?php previous_comments_link() ?></div>
        <div class="alignright"><?php next_comments_link() ?></div>
      </div>
      <?php else : // this is displayed if there are no comments so far ?>
        <?php if ('open' == $post->comment_status) : ?>
          <!-- If comments are open, but there are no comments. -->
        <?php else : // comments are closed ?>
          <!-- If comments are closed. -->
          <p class="nocomments">Comments are closed.</p>
        <?php endif; ?>
      <?php endif; ?>
  2. That's actually pretty simple, simpler than before 2.7, but we'll need to do a couple of things to separate the tweetbacks and trackbacks/pingbacks.
  3. First, open up your themes single.php file, and locate the following code:
    <?php comments_template(); ?>

    And change it to:

    <?php comments_template('',true); ?>
  4. Now open up comments.php, and find the following:
    <?php if ( have_comments() ) : ?>

    Add this below it:

    <?php if ( !empty($comments_by_type['comment']) ) : ?>

    And change this:

    <?php wp_list_comments(); ?>

    Into this:

    <?php wp_list_comments('type=comment'); ?>
  5. Directly underneath this wp_list_comments function you'll find </ol>, below this, add:
    &lt;?php endif; ?&gt;
  6. Now we'll add the tweetbacks below it:
    &lt;?php if ( ! empty($comments_by_type[&#x27;tweetback&#x27;]) ) : ?&gt;
      &lt;h3 id=&quot;pings&quot;&gt;Tweetbacks&lt;/h3&gt;
      &lt;ol class=&quot;commentlist&quot;&gt;
      &lt;?php wp_list_comments(&#x27;type=tweetback&#x27;); ?&gt;
      &lt;/ol&gt;
    &lt;?php endif; ?&gt;

    And the pingbacks below that:

    &lt;?php if ( ! empty($comments_by_type[&#x27;pings&#x27;]) ) : ?&gt;
      &lt;h3 id=&quot;pings&quot;&gt;Trackbacks/Pingbacks&lt;/h3&gt;
      &lt;ol class=&quot;commentlist&quot;&gt;
      &lt;?php wp_list_comments(&#x27;type=pings&#x27;); ?&gt;
      &lt;/ol&gt;
    &lt;?php endif; ?&gt;

For more customization, see this post by Sivel.

Subscribe to the RSS feed or to weekly email updates, right now!