Title: Single Post Category Template
Last modified: August 18, 2016

---

# Single Post Category Template

 *  [sithicus](https://wordpress.org/support/users/sithicus/)
 * (@sithicus)
 * [19 years, 12 months ago](https://wordpress.org/support/topic/single-post-category-template/)
 * I want to change the single post page depending on the category. I was trying
   to use the plugin found here…
 * [http://boren.nu/archives/2005/03/13/custom-post-templates-plugin/](http://boren.nu/archives/2005/03/13/custom-post-templates-plugin/)
 * but for some reason I can’t get it to work.
 * Here is my version of the plugin… anybody see anything wrong with this.. I just
   drop the template in the same folder as the rest of the theme files right?
 * <?php
 * /*
    Plugin Name: Custom Post Templates Plugin URI: [http://boren.nu/](http://boren.nu/)
   Description: Load custom single post templates. Author: Ryan Boren Version: 0.9
   Author URI: [http://boren.nu/](http://boren.nu/) */
 * function cpt_custom_post_template($template) {
    global $wp_query;
 *  $post = $wp_query->post;
    $id = $post->ID;
 *  // If a template exists for this post ID, load it.
    if ( file_exists(TEMPLATEPATH.“/
   single-{$id}.php”) ) return TEMPLATEPATH . “/single-{$id}.php”;
 *  // Add custom checks here. For example, give posts different templates
    // depending
   on what categories they are in. if ( in_category(’15’) && file_exists(TEMPLATEPATH.“/
   single-cat-15.php”) ) return TEMPLATEPATH . ‘/single-cat-15.php’;
 *  if ( in_category(’16’) && file_exists(TEMPLATEPATH . “/single-cat-16.php”) )
   
   return TEMPLATEPATH . ‘/single-cat-16.php’;
 *  return $template;
    }
 * add_filter(‘single_template’, ‘cpt_custom_post_template’);
    ?>
 * Any help would be greatly appreciated.
 * Thanks

Viewing 1 replies (of 1 total)

 *  [greeenkaos](https://wordpress.org/support/users/greeenkaos/)
 * (@greeenkaos)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/single-post-category-template/#post-391175)
 * I’ve got this working on my site. You put the plugin into the plugins directory
   and activated it, right?

Viewing 1 replies (of 1 total)

The topic ‘Single Post Category Template’ is closed to new replies.

## Tags

 * [catagories](https://wordpress.org/support/topic-tag/catagories/)
 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [templates](https://wordpress.org/support/topic-tag/templates/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [greeenkaos](https://wordpress.org/support/users/greeenkaos/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/single-post-category-template/#post-391175)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
