Forums

Other single template (2 posts)

  1. stevenoi
    Member
    Posted 4 months ago #

    Hi, I got a little code which display's another single template than the default single.php if you're viewing category 1.

    <?php if ( in_category('1')) {include(TEMPLATEPATH.'/single-portfolio.php');
    } else { ?>

    But when I'm viewing a subcategory of category 1, it will display the default single.php instead of single-portfolio.php.

    Hope you can help me, Steven.

    [moderated--bump removed. Please refrain from bumping as per Forum Rules]

  2. MichaelH
    moderator
    Posted 4 months ago #

    Could do this:

    <?php if ( in_category(array(1,2,5))) {include(TEMPLATEPATH.'/single-portfolio.php');

    Also see the discussions at Template_Tags/in_category including "Testing if a post is in a descendant category".

Reply

You must log in to post.

About this Topic

Tags

No tags yet.