WordPress.org

Ready to get started?Download WordPress

Forums

Single post templates (4 posts)

  1. Kristen
    Member
    Posted 2 years ago #

    Hello,

    I am using this solution: http://wordpress.org/support/topic/have-a-second-singlephp-file-for-different-single-post-look?replies=29

    Like this:

    <?php
    $post = $wp_query->post;
    if ( in_category('5') ) {
    include("single2.php");
    } else {
    include("single1.php");
    }
    ?>

    to give a different look to posts of a certain category. I need to do this for 2 categories, not just 1. How would I add another category to this?

    Any help is appreciated! Thanks!

  2. nsathees
    Member
    Posted 2 years ago #

    If you want different theme for both of them then use this

    <?php
    $post = $wp_query->post;
    if ( in_category('5') ) {
    include("single2.php");
    }elseif(in_category('7')) {
    include("single3.php");
    } else {
    include("single1.php");
    }
    ?>

  3. Jackson
    Member
    Posted 2 years ago #

    You would add an elseif statement, something like this:

    <?php
    $post = $wp_query->post;
    if ( in_category( '5' ) ) {
        include( "single2.php" );
    } elseif( in_category( '6' ) ) {
        include( "single3.php" );
    } else {
        include( "single1.php" );
    }
    ?>
  4. Kristen
    Member
    Posted 2 years ago #

    Thank you both so much for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic