Title: Error with sidebar foreach  function
Last modified: August 19, 2016

---

# Error with sidebar foreach function

 *  [outty](https://wordpress.org/support/users/outty/)
 * (@outty)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/error-with-sidebar-foreach-function/)
 * Hello, I am receiving an error when I click on post links in the sidebar under
   my ‘Recent Posts’.
 * The error is:
 *     ```
       #
   
             Warning: Invalid argument supplied for foreach() in /mnt/w0805/d26/s15/b02ca57e/www/iupgradecanada.com/wp-content/themes/retrospotive-15/sidebar.php on line 47
       ```
   
 * In the sidebar php the code for the ‘foreach()’ is:
 *     ```
       <li><?php _e('Recent Posts'); ?>
       <ul>
       <?php
       $posts = get_posts('numberposts=5&offset=1');
       foreach ($posts as $post) :
       ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></li>
       <?php
       endforeach;
       ?>
       ```
   
 * any help would be appreciated.
 * you can view the error [HERE](http://www.iupgradecanada.com/2008/02/18/opening-soon/)

The topic ‘Error with sidebar foreach function’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [outty](https://wordpress.org/support/users/outty/)
 * Last activity: [18 years, 2 months ago](https://wordpress.org/support/topic/error-with-sidebar-foreach-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
