Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have three loops in my theme that I want to use to get menu items for a lunch, dinner and wine list menu. The first loop worked fine but when I added the second one, the system broke. I did some searching here and they all say not to use $post. So I didn't but I still can't get it to work. I tried adding wp_reset_postdata as seen in the codex and decided to try wp_reset_query() for giggles after doing some searching here but it's still not working. I have been trying to change the variable names but still no joy.

 $lunchargs = array(
        'posts_per_page' => 5,
        'category'       => 'lunch',
        'post_status'    => 'publish',
        'order'          => 'ASC',
 $lunchposts = get_posts($lunchargs);
    foreach( $lunchposts as $post) : setup_postdata( $post );  ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; 
 wp_reset_postdata(); wp_reset_query()?> 

So I repeat the code above three times changing the varaibles in all three loops like so

foreach( $dinnerpost as $post) : setup_postdata( $post );

foreach( $winelist as $post) : setup_postdata( $post );

I also found on here that some say not to use the category slug in the $args but I need to use the slug because I am not sure what the ID of the category will be in the end.

share|improve this question
So it seems that changing 'category' to 'category_name' will work. –  Jamie Oct 22 '13 at 1:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.