Title: Multiple if is_category
Last modified: August 20, 2016

---

# Multiple if is_category

 *  [Lee](https://wordpress.org/support/users/mylemonhead/)
 * (@mylemonhead)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/)
 * Ive an existing code but is too long as ive many categories (>30). If i were 
   to use the below code, it seems too much. Is there a better way to do it?
 *     ```
       <?php if ( is_category('1') || is_category('2') || is_category('3') ) {
           echo 'hi';
       }
       ?>
       ```
   
 * Basically i want all child categories within the main category, not the posts
   under the child categories. Thanks for your time.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710785)
 * [http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of](http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of)?
 *  [Paweł Knapek](https://wordpress.org/support/users/adpawl/)
 * (@adpawl)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710786)
 *     ```
       <?php
       if( is_category( array(9,2,3) ) ) { echo 'hi'; }
       ?>
       ```
   
 *  Thread Starter [Lee](https://wordpress.org/support/users/mylemonhead/)
 * (@mylemonhead)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710798)
 * dpawl: yup, thanks, but is there a way just to include just the child categories
   of the ancestor?
    esmi: im looking towards like the descendants categories, thanks
 *  [Paweł Knapek](https://wordpress.org/support/users/adpawl/)
 * (@adpawl)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710925)
 * [@mylemonhead](https://wordpress.org/support/users/mylemonhead/), [http://codex.wordpress.org/Function_Reference/in_category](http://codex.wordpress.org/Function_Reference/in_category)?
   
   I do not know exactly what you want to get.
 *  Thread Starter [Lee](https://wordpress.org/support/users/mylemonhead/)
 * (@mylemonhead)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710927)
 * thanks for replying adpawl, i stick to the above method you provided. cheers

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

 The topic ‘Multiple if is_category’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [Lee](https://wordpress.org/support/users/mylemonhead/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/multiple-if-is_category/#post-2710927)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
