Title: cannot get data from multiple categories
Last modified: August 30, 2016

---

# cannot get data from multiple categories

 *  [hungpham](https://wordpress.org/support/users/hungpham/)
 * (@hungpham)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/cannot-get-data-from-multiple-categories/)
 * I have this function
 *     ```
       $args = array ( 'cat' => '29,30,31,32', 'orderby' => 'rand', 'posts_per_page' => '1' );
           $the_query = new WP_Query( $args );
           if ( $the_query->have_posts() ) :
               while ( $the_query->have_posts() ) :
                   $the_query->the_post();
                   echo '<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a><br />';
               endwhile;
           endif;
           wp_reset_postdata();
       ```
   
 * It seems running correctly with one record is returned. But somehow, the link
   and the thumbnail returns nothing. If I replace the ‘cat’ with just one value,
   instead of 4 values, it’s working.
 * Am I wrong somewhere? Please suggest.
 * Thanks.

The topic ‘cannot get data from multiple categories’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [hungpham](https://wordpress.org/support/users/hungpham/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/cannot-get-data-from-multiple-categories/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
