Title: Problem using in_category in single.php
Last modified: August 19, 2016

---

# Problem using in_category in single.php

 *  [jonoc73](https://wordpress.org/support/users/jonoc73/)
 * (@jonoc73)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/problem-using-in_category-in-singlephp/)
 * Hi there,
 * I would like to use a template for all the posts in one of my categories. I have
   included the following in my single.php page before the loop. However it passes
   everything as true and therefore sends all the posts to the include regardless
   if it’s a post within the category 22 or not. Can you help?
 *     ```
       <?php if (in_category('22')) { ?>
       	<?php include(TEMPLATEPATH . '/includes/guided-tour.php'); ?>
       	<?php } else { ?>
       ```
   
 * Thanks Jono

Viewing 1 replies (of 1 total)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/problem-using-in_category-in-singlephp/#post-1124182)
 * as this is for a single post, you should be able to put this code within the 
   loop without any problem, and that should solve your problem.

Viewing 1 replies (of 1 total)

The topic ‘Problem using in_category in single.php’ is closed to new replies.

## Tags

 * [in_category](https://wordpress.org/support/topic-tag/in_category/)
 * [single.php](https://wordpress.org/support/topic-tag/single-php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/problem-using-in_category-in-singlephp/#post-1124182)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
