Month: May 2007

  • Separating Trackbacks/Pings from Comments in WordPress

    I was trying to figure out the best way to separate trackbacks/pings from the comments here on the site. I’ve seen a number of tutorials out there, but none seemed to do exactly what I wanted. The code is piece-mealed from a couple of places, but this is how I accomplished it here on the site:

    Backup your existing comments.php file associated with your theme! I cannot stress this enough.

    Assuming you’re using the default theme, or some variation thereof, you’re going to want to look for this in your comments.php file:

    [php]

    < ?php if ($comments) : ?>
    [/php]

    You’re basically going to replace the logic on comments.php from where it says < ?php if ($comments) : ?> (Line 20) to < ?php endif; ?> (Line 61) with the logic below.

    Define the number of pings and comments (Source: Sandbox theme):

    [php]
    < ?php /* NUMBERS OF PINGS AND COMMENTS */ $ping_count = $comment_count = 0; foreach ( $comments as $comment ) get_comment_type() == "comment" ? ++$comment_count : ++$ping_count; ?>
    [/php]

    Then check to see whether comment_status is set to 'open'. If it is 'open', we then check to make sure the comment_count isn’t equal to zero. Once these conditions are met, I then display only the comments. Some other conditional logic is included, like checking whether the comment’s being held for moderation:

    [php]
    < ?php if ('open' == $post-> comment_status) : ?>
    < ?php if ( $comment_count ) : ?>
    < ?php if ($comments) : ?>

    Stuff said in regard to this entry:

      < ?php foreach ($comments as $comment) : ?>
      < ?php if (get_comment_type() == "comment"){ ?>

    1. ” alt=”” />

    < ?php comment_author_link() ?> < ?php _e('said'); ?>:

    < ?php comment_text() ?>

    < ?php if ($comment->comment_approved == ‘0’) : ?>

    Your comment is awaiting moderation.

    < ?php endif; ?>

    Posted < ?php comment_date('F j, Y') ?> @
    ‘, ”); ?>

  • < ?php /* Changes every other comment to a different class */ if ('alt' == $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?>
    < ?php } ?>
    < ?php endforeach; /* end for each comment */ ?>

    < ?php else : ?>
    < ?php endif ?>

    < ?php else : ?>

    Hey, there’s no comments on this post!

    How about being the first?

    < ?php endif /* if ( $comment_count ) */ ?>

    < ?php else : // comments are closed ?>

    < ?php /* Comments are closed */ ?>

    Sorry dude, comments are closed on this post. If you had stuff you liked to say about this entry,
    feel free to contact me.

    < ?php endif; /* if ('open' == $post-> comment_status) */ ?>
    [/php]

    Then we do the same thing for trackback/pings:

    [php]
    < ?php if ( pings_open() ) : ?>
    < ?php if ( $ping_count ) : ?>

    Trackback/Ping Stuff:

      < ?php foreach ($comments as $comment) : ?>
      < ?php if (get_comment_type() != "comment") : ?>

    1. < ?php comment_date('F jS, Y') ?> at < ?php comment_time() ?> < ?php edit_comment_link('e',' ‘, ‘‘); ?>
    2. < ?php /* Changes every other comment to a different class */ if ('alt' == $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?>
      < ?php endif; ?>
      < ?php endforeach; /* end for each comment */ ?>

    < ?php else : /* if ( $ping_count ) */ ?>

    < ?php endif /* if ( $ping_count ) */ ?>

    < ?php else : // pings are a no-go bro. ?>

    < ?php /* Pings are a no-go, bro. */ ?>

    Pings are a no-go, bro.

    Maybe next time?

    < ?php endif /* if ( pings_open() ) */ ?>
    [/php]

    Save the changes and you should be good to go.

    Hopefully this is a pretty straightforward implementation… If you have any better ideas, I’d love to hear ’em.

  • Happy Birthday, Mr. Reznor

    Happy Birthday, Mr. Reznor. Thank you for the gift that is Year Zero. I can’t stop listening to it… Bonus link: NIN Remixes.

  • Google Experimental

    Google Experimental. Feeling left out? Want to take Google’s new search layouts for a test drive?

  • A Mini-Design Update

    You may or may not have noticed, but I rolled out a few design changes shortly after I upgraded to WordPress 2.2 yesterday morning.

    • I changed the color scheme a bit. Went from a dark blue background with white text to a white background with black text. It’s not a major change, but I’m hoping it’ll help with readability. More significant changes will probably be coming in the next week or so. (I’m still trying to wrap up a few projects I’ve been working on for a while, so depending on how quickly those are finished will determine how soon I get to play again with the site design.)
    • I reworked how Comments and Pings/Trackbacks are displayed on individual post items. Previously, trackbacks were displayed inline with regular comments. Now, they’re not. They used to be included in <div>s, now they’re in an <ol>. (These are subtle changes, I know, but I’m trying to improve the semantics in the markup for the site.)

    The way I’m versioning the site is sort of weird – and pretty arbitrary – to be honest with you. I’m calling this Version 14.1.0 because of some improvements I made in the code structure for my site template and some CSS changes that I made. But the reality is, I have no idea what version the site is at currently. Hopefully I can do a better job at explaining some more of the changes I make in the near future.

    (Thanks, Matt, for the nudge to do this.)

  • First Impressions of WordPress 2.2

    I upgraded my site to WordPress 2.2 without any problems this morning. I’m not sure if it’s enough of a difference from 2.1.3 to justify the upgrade for most users, but I’m a sucker for new software. In this release they’ve added support for WordPress Widgets without requiring a plugin. Among other things, the latest WordPress release also features full Atom support, a new Blogger importer, a revised Comment admin page (with AJAX-y goodness!), and a new plugin “protection system” – that will prevent you from installing a plugin that will break your site.

    • The Comment admin page now displays the last 20 comment, no matter what. When you delete a comment, the next comment dynamically gets pulled into the page.
    • WordPress 2.2 broke the FlickrRSS plugin somehow. I’ll need to look into how to remedy that…

    All in all some nice additions, but again… not sure if it’s enough to justify an upgrade for most folks.

  • WordPress 2.2 Available

    WordPress 2.2 Available. I’ll be upgrading sometime this morning.

  • Web Design Survey

    Over 30,000 people have taken The Web Design Survey, have you? (I have!) The survey closes on May 22nd. If you haven’t taken the survey yet, now’s the time to act!

  • So, umm, where you want to meet?

    So, umm, where do you want to meet for lunch? This might just be a godsend for some folks. Nice use of the Google Maps API.

  • Wiikly Update: 14 May 2007

    Three new (old) titles hit the Wii Virtual Console today: Pac-Man (NES, 1-2 players, 500 Wii Points); Ninja Gaiden (NES, 1 player, 500 Wii Points); and Ninja Spirit (TurboGrafx16, 1-2 players, 600 Wii Points).

  • Game On!

    Game On! This collection of 100 playable NES games is definitely going to kill some time… (Hat tip: JuberJabber)