Title: Where to insert code for category theme?
Last modified: August 18, 2016

---

# Where to insert code for category theme?

 *  [fallingj](https://wordpress.org/support/users/fallingj/)
 * (@fallingj)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-code-for-category-theme/)
 * I want to make posts from different categories look different from one another:
 * `<?php
    $post = $wp_query->post; if ( in_category('9') ) { include(TEMPLATEPATH.'/
   single2.php'); } else { include(TEMPLATEPATH . '/single1.php'); } ?>
 * But where do I put this piece of code? Does it go in the The Loop? Or does it
   go in template page (single2.php in the example)?
 * Silly question, but I would be appreciative if someone could help.

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

 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-code-for-category-theme/#post-371897)
 * Perhaps there’s an easier way. See this article: [Category_Templates](http://codex.wordpress.org/Category_Templates)
 * I’m thinking that [this section](http://codex.wordpress.org/Category_Templates#What_Template_Displays_a_Particular_Category)
   would be along the lines of what you’re trying to do?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-code-for-category-theme/#post-371898)
 * You may want to check out my plugin as well:
 * [http://guff.szub.net/2005/07/21/post-templates-by-category/](http://guff.szub.net/2005/07/21/post-templates-by-category/)
 *  Thread Starter [fallingj](https://wordpress.org/support/users/fallingj/)
 * (@fallingj)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-code-for-category-theme/#post-371906)
 * Thanks for the great reply.
 * I had to add the code to single.php. I’m just looking for a way to style posts
   that are in multiple categories. So the same post in category A will look different
   than the same post in category B.
 * Your plugin looks fantastic. I will certainly be using it.
 * Keep up the good work!

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

The topic ‘Where to insert code for category theme?’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [fallingj](https://wordpress.org/support/users/fallingj/)
 * Last activity: [20 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-code-for-category-theme/#post-371906)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
