Title: Custom Single.php pages
Last modified: August 19, 2016

---

# Custom Single.php pages

 *  [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * (@daenterpri)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/custom-singlephp-pages/)
 * Hello,
 * I have a custom single.php file for all of my posts that are part of my websites
   business directory. Here is what the single.php file looks like, every post part
   of the business directory gets the “singledir.php” template:
 *     ```
       <?php
         $post = $wp_query -> post;
         if ( in_category( array( 'insurance', 'website-design') ) ) {
         include(TEMPLATEPATH . '/singledir.php');
         } elseif ( in_category('2') ) {
         include(TEMPLATEPATH . '/single2.php');
         } else {
         include(TEMPLATEPATH . '/single1.php');
         }
       ?>
       ```
   
 * Right now I have to list every sub-category in an array. Is there any way that
   I can just have it grab all of the sub categories of “business-directory”, or“
   195”?
 * Thanks,
 * Andy

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

 *  Thread Starter [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * (@daenterpri)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/custom-singlephp-pages/#post-1063290)
 * Anyone? It seems like this would be simple, but I cannot find anything.
 *  [brainycat](https://wordpress.org/support/users/brainycat/)
 * (@brainycat)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/custom-singlephp-pages/#post-1063292)
 * If I’m understanding correctly, you want to dynamically find all the sub-cats
   for cat_ID=195 to pass to in_category()?
 * I haven’t actually coded any functionality like that, but I think [http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of](http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of)
   is what you’re looking for.
 *  Thread Starter [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * (@daenterpri)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/custom-singlephp-pages/#post-1063309)
 * Ah, thanks! I think that is the right track.

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

The topic ‘Custom Single.php pages’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/custom-singlephp-pages/#post-1063309)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
