WordPress

WordPress Code Snippet: Display Latest Comment Excerpt Per Post on index.php

by Steve / WordPress

I first got the idea for this useful WordPress code snippet whilst browsing video gaming blog Destructoid. Basically, I wanted to extract the latest comment from each post and display a short excerpt of it on the blog homepage (index.php). I've included a screenshot below to give you an idea of the final result: [ [...] Read more »

WordPress Code Snippet: Display Total Number of Posts

by Steve / WordPress

Just a quick and dirty code snippet which basically allows you to display the total number of posts which have been published on your blog: <?php $numpost = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'"); echo $numpost; ?> There's nothing pretty about it - it'll need some spicing up but I'm sure you'll be [...] Read more »