Title: Sidebar problem: get_posts function not working properly! Please help..
Last modified: August 19, 2016

---

# Sidebar problem: get_posts function not working properly! Please help..

 *  Resolved [rage00001](https://wordpress.org/support/users/rage00001/)
 * (@rage00001)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/sidebar-problem-get_posts-function-not-working-properly-please-help/)
 * 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](http://www.sinna.no)
 * Thanks for all help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 4 months ago](https://wordpress.org/support/topic/sidebar-problem-get_posts-function-not-working-properly-please-help/#post-682248)
 * 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](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](https://wordpress.org/support/users/rage00001/)
 * (@rage00001)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/sidebar-problem-get_posts-function-not-working-properly-please-help/#post-682375)
 * 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.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [rage00001](https://wordpress.org/support/users/rage00001/)
 * Last activity: [18 years, 4 months ago](https://wordpress.org/support/topic/sidebar-problem-get_posts-function-not-working-properly-please-help/#post-682375)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
