Musings

Finally! Fixed the sort order of the posts in WordPress

Had been puzzling over the sort order of the posts in WordPress since a recent upgrade. For no reason, it kept showing the earliest post first instead of latest.

Here’s the solution!


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

add_filter( 'posts_groupby', 'plw123ngb_posts_groupby' );

http://schnurpsel.de/wordpress-und-die-suboptimale-mysql-optimierung-5051-74/
http://wordpress.org/support/topic/how-do-i-fix-the-sort-order-of-my-posts

Standard

One thought on “Finally! Fixed the sort order of the posts in WordPress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s