Title: Single Post Template Problem&#8230;?
Last modified: August 19, 2016

---

# Single Post Template Problem…?

 *  [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/single-post-template-problem-1/)
 * I have been using [this](http://elliotjaystocks.com/blog/tutorial-multiple-singlephp-templates-in-wordpress/)
   tutorial for creating post templates ready rather than having them selected in
   the admin with a plugin.
 * However, i have run into a problem..
 * My single.php has this code in..
 *     ```
       <?php
       if (in_category('1')) {include (TEMPLATEPATH . '/single-1.php');
       }
       if (in_category('3')) {include (TEMPLATEPATH . '/single-3.php');
       }
       else { include (TEMPLATEPATH . '/single-default.php');
       }
       ?>
       ```
   
 * i.e if cat 1 show singe-1 if cat 3 show single-3 however, its not working properly,
   the single-1 is all messed up whilst the single-3 is fine.
 * Is the code connected properly via php? If not how do i connect it so it does
   the job it should…
 * Many thanks 🙂

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

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/single-post-template-problem-1/#post-1259583)
 * It looks ok structurally. However, if you are on cat == 1 this code will load`
   single-1` **and** `single-3` **or** `single-default`. I’m not sure if that is
   what you want. A nagging voice in my skull is telling me you want something like…
 *     ```
       if (in_category('1')) {
         include (TEMPLATEPATH . '/single-1.php');
       } elseif (in_category('3')) {
         include (TEMPLATEPATH . '/single-3.php');
       } else {
         include (TEMPLATEPATH . '/single-default.php');
       }
       ```
   
 * … but you know it is with voices. Can’t trust ’em.
 * As for why your layout is broken, it probably has something to do with loading`
   single-1` and `single-default` vs `single-1` and `single-3` vs. only `single-
   3` vs. only `single-default`. I’m guessing you are getting tag mis-matches depending
   upon which files load.
 * An URL would help if you’ve got one.
 *  Thread Starter [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/single-post-template-problem-1/#post-1259761)
 * Thanks so much thats worked a treat 🙂
 * And if i wanted to add more single’s would it work like this…?
 *     ```
       if (in_category('1')) {
         include (TEMPLATEPATH . '/single-1.php');
       } elseif (in_category('3')) {
         include (TEMPLATEPATH . '/single-3.php');
       } elseif (in_category('4')) {
         include (TEMPLATEPATH . '/single-4.php');
       } else {
         include (TEMPLATEPATH . '/single-default.php');
       }
       ```
   
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/single-post-template-problem-1/#post-1259769)
 * Yes. You can add as many `elseif`‘s as you want, but if you start to get a very
   long string of them you might try to think of a different approach.

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

The topic ‘Single Post Template Problem…?’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/single-post-template-problem-1/#post-1259769)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
