Title: Checking if category has posts
Last modified: August 19, 2016

---

# Checking if category has posts

 *  Resolved [newkind](https://wordpress.org/support/users/newkind/)
 * (@newkind)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/checking-if-category-has-posts/)
 * Hi,
 * I would like to do such thing :
 * I’ve got a table which displays posts from category ‘test’. Posts are displayed
   using standard
 *     ```
       <?php query_posts('category_name=test&amp;showposts=3'); ?>
        <?php while (have_posts()) : the_post(); ?>
       ```
   
 * But i’d like to add another loop above this loop (and above the wrapper that 
   this loop is inside of) so it would check if the category ‘test’ has posts – 
   if so go and do the loop mentioned above, if not – display nothing. Or maybe 
   there is another way to hide a theme module ?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/checking-if-category-has-posts/#post-1062759)
 * $test=get_posts(‘category_name=test’);
    if ($test) { //found posts }
 *  Thread Starter [newkind](https://wordpress.org/support/users/newkind/)
 * (@newkind)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/checking-if-category-has-posts/#post-1062811)
 * thank you 🙂
 *  [johnnyriss](https://wordpress.org/support/users/johnnyriss/)
 * (@johnnyriss)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/checking-if-category-has-posts/#post-1062934)
 * awesome. thx much
 *  [Brendino](https://wordpress.org/support/users/brendino/)
 * (@brendino)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/checking-if-category-has-posts/#post-1062939)
 * This helped me!
 * Thanks, MichaelH 😀

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

The topic ‘Checking if category has posts’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [hide](https://wordpress.org/support/topic-tag/hide/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [module](https://wordpress.org/support/topic-tag/module/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * 4 replies
 * 4 participants
 * Last reply from: [Brendino](https://wordpress.org/support/users/brendino/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/checking-if-category-has-posts/#post-1062939)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
