WordPress.org

Support

is_single

  • 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');
    else
    include ('sidebar.php');
    ?>

    What am I doing wrong?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘is_single’ is closed to new replies.
Skip to toolbar