WordPress.org

Forums

[resolved] Querying Single.php Pages? Query/Design Problems. (6 posts)

  1. mrleesimpson
    Member
    Posted 7 years ago #

    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/

    <?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?

  2. moshu
    Member
    Posted 7 years ago #

    single.php displays the single post view.
    page.php displays the Pages.
    see 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/

  3. mrleesimpson
    Member
    Posted 7 years ago #

    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.

  4. mrleesimpson
    Member
    Posted 7 years ago #

    Right.

    I've managed to the get the actual query to work (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?

  5. mrleesimpson
    Member
    Posted 7 years ago #

    HAHA!

    Fixed the problem less than 5 minutes later

    Thanks to anyone who took a look at this.

  6. zedesino
    Member
    Posted 7 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic