Title: Querying Single.php Pages? Query/Design Problems.
Last modified: August 19, 2016

---

# Querying Single.php Pages? Query/Design Problems.

 *  Resolved [mrleesimpson](https://wordpress.org/support/users/mrleesimpson/)
 * (@mrleesimpson)
 * [18 years ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/)
 * Hello,
 * I’m trying to achieve a seperate Single page for 3 categories (Graphic Design,
   Website Design & Blog), I managed to track down the code I need and arranged 
   the files as required. However for some reason I’m have two problems.
 * **One:** When I use the code bellow in the single.php file to query two Single
   Pages it messes up the CSS of the single page it leads you to i.e. [http://dev.mrleesimpson.co.uk/2008/04/test-post-image/](http://dev.mrleesimpson.co.uk/2008/04/test-post-image/)
 *     ```
       <?php
       $post = $wp_query->post;
       if ( in_category('3') ) {
          include(TEMPLATEPATH . '/single_graphic.php');
       } else {
          include(TEMPLATEPATH . '/single_blog.php');
       }
       ?>
       ```
   
 * **Two:** When I try to use the code bellow in the single.php file, to query 3
   different Single Pages it won’t work at all.
 *     ```
       <?php
         $post = $wp_query- >post;
   
         if ( in_category('4') ) {
         include(TEMPLATEPATH . '/single_website.php');
   
         } elseif ( in_category('3') ) {
         include(TEMPLATEPATH . '/single_design.php');
   
         } else {
         include(TEMPLATEPATH . '/single_blog.php');
   
         }
       ? >
       ```
   
 * So it’ll query 2 but it messes up the page layout and it just won’t query 3 at
   all.
 * Has anyone got any ideas?

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

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-749675)
 * single.php displays the single post view.
    page.php displays the [Pages](http://codex.wordpress.org/Pages).
   see [Template_Hierarchy](http://codex.wordpress.org/Template_Hierarchy)
 * Not clear what kind of pages/Pages are you talking about.
 * For having diffent single post view by categories, use this plugin:
    [http://guff.szub.net/2005/07/21/post-templates-by-category/](http://guff.szub.net/2005/07/21/post-templates-by-category/)
 *  Thread Starter [mrleesimpson](https://wordpress.org/support/users/mrleesimpson/)
 * (@mrleesimpson)
 * [18 years ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-749707)
 * Sorry. I’m talking about single post views.
 * So I want the single post view for each category to use a different single page
   template.
 * Website Design = single_website.php
    Graphic Design = single_graphic.php Eveything
   Else = single_blog.php
 * I really hope someone can help me out with this.
 *  Thread Starter [mrleesimpson](https://wordpress.org/support/users/mrleesimpson/)
 * (@mrleesimpson)
 * [18 years ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-749714)
 * **Right.**
 * I’ve managed to the get the actual query to work ([http://dev.mrleesimpson.co.uk/2008/04/test-graphic-post](http://dev.mrleesimpson.co.uk/2008/04/test-graphic-post)).
   But I’m still have the problem with the design.
 * The footer and sidebar seem to right out.
 * Anyone?
 *  Thread Starter [mrleesimpson](https://wordpress.org/support/users/mrleesimpson/)
 * (@mrleesimpson)
 * [18 years ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-749716)
 * **HAHA!**
 * Fixed the problem less than 5 minutes later
 * Thanks to anyone who took a look at this.
 *  [zedesino](https://wordpress.org/support/users/zedesino/)
 * (@zedesino)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-750161)
 * hello, can you paste the code here becouse i have the same problem
 * <?php
    $post = $wp_query->post; if ( in_category(’27’) ) { include(TEMPLATEPATH.‘/
   single3.php’); } if ( in_category(’21’) ) { include(TEMPLATEPATH . ‘/single2.
   php’); } else { include(TEMPLATEPATH . ‘/single1.php’); } ?>
 * or i tryed like this
 * <?php
    $post = $wp_query->post; if ( in_category(‘21,27’) ) { include(TEMPLATEPATH.‘/
   single2.php’); } else { include(TEMPLATEPATH . ‘/single1.php’); } ?>
 * but doesnt work
 * help please

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

The topic ‘Querying Single.php Pages? Query/Design Problems.’ is closed to new replies.

## Tags

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

 * 5 replies
 * 3 participants
 * Last reply from: [zedesino](https://wordpress.org/support/users/zedesino/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/querying-singlephp-pages-querydesign-problems/#post-750161)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
