• Resolved rage00001

    (@rage00001)


    Ok..
    I have this in my sidebar, and this have been working fine for over one year and many versions of WP.

    <ul>
     <?php
     $myposts = get_posts('numberposts=20&offset=5');
     foreach($myposts as $post) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul><br />

    I think the problem started when we changed to the year 2008.

    Now it’s totally wrong, and don’t show the just archived post with an offset of 5. The post shown there are really old…

    look here: http://www.sinna.no

    Thanks for all help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    This is the MySQL 5.0.50/51 bug. Looks like your host just upgraded their MySQL version. Unfortunately a lot of hosts are upgrading MySQL now, and they’re all doing it to these buggy versions. WordPress is doing the right thing, their version of MySQL is not.

    Quick hack/fix:
    Find this in wp-includes/post.php (around line 260):
    $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order;

    Change it to this:
    $query .= " ORDER BY $orderby $order";

    That should solve it. But this is a temporary fix only, some other types of get_posts calls won’t work with this fix.

    Meanwhile, tell your host that they need to upgrade to at least MySQL version 5.0.52, because 5.0.50 and 51 have a bug that causes this problem: http://bugs.mysql.com/bug.php?id=32202

    If your host wants more information, tell them to come here and ask. We’ll tell them all about it.

    Thread Starter rage00001

    (@rage00001)

    Thank You!!
    when i changed the code as you told me, everything is just fine as it should be…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sidebar problem: get_posts function not working properly! Please help..’ is closed to new replies.