WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sorting blog posts (4 posts)

  1. andersdrengen
    Member
    Posted 6 years ago #

    Hi,

    For some weird reason all my blog posts 200+ are now sorted reverse when I enter my page. I've done nothing (really!) as I've been offline for a period of time.

    Anyway, when looking at the blog main page it says "blablabla, posted 2 years and 10 months ago" - when scrolling to the 'last' page it shows my newest post, a few days ago.

    Can somebody point me to something that can reverse the posts? Everything works fine...

    Thanks a lot!

  2. andersdrengen
    Member
    Posted 6 years ago #

    Got this one myself, so it's solved now - it's due to a problem/error in MySQL v. 5.0.51 that creates this behaviour. Upgrading to 5.0.52 resolves this. If that's not possible, I found this piece of code that can be used instead as plugin...

    <?php
    /*
    Plugin Name: 123 No Group By ID
    Plugin URI:
    Description: Changes the GROUP BY id in GROUP BY post_date (Problem from MySQL 5.0.51).
    Author: Ingo Henze
    Version: 0.10
    Author URI: http://putzlowitsch.de/
    */ 
    
    // GROUP BY auswerten
    function plw123ngb_posts_groupby( $groupby ) {
    if( preg_match( “/(|[ ,.])id(|[ ,])/i”, $groupby ) )
    $groupby = ‘post_date’;
    return $groupby;
    }
    
    add_filter( ‘posts_groupby’, ‘plw123ngb_posts_groupby’ );
    ?>
  3. missylovely
    Member
    Posted 6 years ago #

    where do I insert these codes?

  4. gummybear
    Member
    Posted 6 years ago #

    Missylovely: I am having the same problem and this code fixed it for me. My categories page show the correct post order (Descending) but the main page is in Ascending order.

    Go into your admin control panel. Go to PRESENTATION > Theme Editor. Find the home page file for your theme. Usually this file is the index.php or home.php file.

    I would copy and paste the above code and add it after the <?php get_header(); ?> line

Topic Closed

This topic has been closed to new replies.

About this Topic