Wordpress problems - posts in reverse order - fix - howto

Created 17 years ago by Matt,
Last updated August 5th 2024, 3:50:07 pm

I recently had to fix a problem with a wordpress installation, which appeared to be generating the posts in reverse order.

Having searched around, I found a solution here, which was basically to add a plugin to wordpres, that adds a filter to the posts, ordering them by date_posted.

The following code should be put into a file, within the wp-content/plugins section of the wordpress installation, with a .php extension:

// GROUP BY function tempfixgb_posts_groupby( $groupby ) { if( preg_match( "/(|[ ,.])id(|[ ,])/i", $groupby ) ) $groupby = 'post_date'; return $groupby; }

add_filter( 'posts_groupby', 'tempfixgb_posts_groupby' ); ?>

Then you need to activate the plugin in the Wordpress admin section under plugins

based on post by Ingo Henze