is_single (2 posts)

  1. davedorm
    Posted 10 years ago #

    I am trying to show two different sidebars, one on the home page, one on pages and single posts. Here's what I have so far on index.php

    <?php if (is_single(true))
    include ('sidebar2.php');
    include ('sidebar.php');

    What am I doing wrong?

  2. geoffe
    Posted 10 years ago #

    you don't want true in there as a passed variable and I presume you have considered making a separate single.php and/or page.php template in your theme folder to deal with different formatting/layout.

    What I've done is to use the conditional tags in sidebar.php, so that when sidebar.php is called, it will test if it's a story page or an author page. And as you can see on that page I linked, you can send the ID # or title or slug of a post with is_single but true would fool the function.

Topic Closed

This topic has been closed to new replies.

About this Topic