I Dream in Colors

Hi, I'm Nico :)

08/21/07 Recent posts on Wordpress

One of the best Recent Posts plugins for Wordpress out there is the Coffe2Code Customizable Post Listings. In fact, it does much more. “Display Recent Posts, Recently Commented Posts, Recently Modified Posts, Random Posts, and other post listings…”. Neat.

But, since Wordpress 2.1, there’s a slight problem with it. You see, WP 2.1 changed the way Pages work, so this nifty plugin now fails to tell the difference between posts and Pages. It may not be too much of a problem in some cases, but in this particular site I’m currently working on it gets in the way. Fortunately, there’s an easy fix.

All that needs to be added is this little snippet of code that tells the plugin to only process the posts and not the Pages: post_type=’post’. One doesn’t need to know PHP to do this (I don’t…). Copy and paste will do.

Look for this:


$sql .= “WHERE $tableposts.post_date <= '$now' AND ( $tableposts.post_status = 'publish' ";
if ($include_sticky_posts) $sql .= "OR $tableposts.post_status = 'sticky' ";
$sql .= ")";



and add the bit of code mentioned before, like this:


$sql .= “WHERE $tableposts.post_date <= '$now' AND ( $tableposts.post_status = 'publish' ";
if ($include_sticky_posts) $sql .= "OR $tableposts.post_status = 'sticky' ";
$sql .= ") AND $tableposts.post_type=’post’ “;

Now it works like a charm :).

Unfortunately this pluging hasn’t been updated in a few years, and even the last comment about it on the website is from 2005. At least this will leave them a pingback.

Technorati Tags: , , , ,

2 comments

OMG! A POST!

There is a recent post plugin? I thought it was built in to wordpress – I just use a widget.

unless wordpress 2.2 fixed the problem?

also: mollie got the dolls.

With the plugin you can put recent posts and comments outside the sidebar, like on Soccerlens.com. That’s the main difference.

Good about the dolls!! I was wondering if the Canadian or US postal service had ate them or something :)



Speak your mind

(required)

(required - not published)