Title: have_posts() is empty
Last modified: August 20, 2016

---

# have_posts() is empty

 *  Resolved [ayok](https://wordpress.org/support/users/ayok/)
 * (@ayok)
 * [14 years ago](https://wordpress.org/support/topic/have_posts-is-empty/)
 * Hi, I’m new to WP. I have problem to show looping post from a category.
    Here
   is the codes
 *     ```
       <ul id="sliderContent">
       <?php
       $my_query = new WP_Query('showposts=18&category_name=slides');
       if ( $my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post();
       $do_not_duplicate = $post->ID;
       $thumb = get_post_meta($post->ID, 'thumb-large', true);
       ?>
       <li class="sliderImage">
       <img src="<?php echo $thumb; ?>" alt="<?php the_title() ?>" />									</li>
       <?php endwhile; ?>
       <?php endif; ?>
       </ul>
       ```
   
 * This codes return empty. I’ve looked on WP tutorials on the internet, this code
   has no problem. But why are there no images. $my_query->have_posts() returns 
   just empty.
 * The owner said it was working before.
    Could someone tell me what’s happened?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/have_posts-is-empty/#post-2727013)
 * > This codes return empty
 * just on the screen, or even in the html of the page?
    i.e. do you just get the
   ul tags?
 *     ```
       <ul id="sliderContent">
       </ul>
       ```
   
 * – does the category ‘slides’ exist and have posts?
    i.e. can you get to the normal
   category archive of ‘slides’ and get all the posts?
 * – does the query work if you use the ‘slides’ category ID with the corresponding
   code? example: `('showposts=18&cat=231')`
 *  Thread Starter [ayok](https://wordpress.org/support/users/ayok/)
 * (@ayok)
 * [14 years ago](https://wordpress.org/support/topic/have_posts-is-empty/#post-2727015)
 * Hi alchymyth.
    I just got the solution from the template maker, [simplefolio](http://billxinli.com/2011/02/24/simplefolio-and-wordpress-3-1-fix/).
 *     ```
       $category = sf_get_category_id(get_option('sf_portfolio_category'));
       $slide_count = (get_option('sf_slider_slides')) ? get_option('sf_slider_slides') : 18;
       $text_count = (get_option('sf_slider_chars')) ? get_option('sf_slider_chars') : 100;
   
       $my_query = new WP_Query('showposts='.$slide_count.'&cat='.$category);
       ```
   
 * Thanks for the fast reply.

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

The topic ‘have_posts() is empty’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [ayok](https://wordpress.org/support/users/ayok/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/have_posts-is-empty/#post-2727015)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
