WordPress.org

Support

Support » How-To and Troubleshooting » template for different pages

template for different pages

  • Another day, another noobie question… I want a different sidebar on a secondary page. How would I go about doing this, as <?php get_sidebar(); ?> gets the template sidebar for all pages. In short, I want a sidebar for the homepage and one (or multiple) for other pages. I know this is possible, I just don’t know how to do it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You might start by looking over the Conditional_Tags. You can use those to help determine what you want to display in your sidebar -or- which sidebar you want to show, depending on how you structure things.

    By way of an example, I only want to show top commentators (a plugin) on my home page. So, in my sidebar.php, I have the following:

    <?php if (is_home()) { ?>
       <?php if(function_exists('ns_show_top_commentators')) { ?>
          <h2>Top Commentators</h2>
          <ul>
             <?php ns_show_top_commentators(); ?>
          </ul>
       <?php } ?>
    <?php } ?>

    Thanks. I learned a lot. However, this does not work:

    <?php if ( is_home() ) { ?>

    ..stuff on page…

    <?php } ?>

    And I think because the “home” page lives outside of the normal blog chronology, it is a “page,” not a post ( I am using the Mimbo template).

    I think this might work but I am not sure of the syntax exactly:

    is_page(home)

    Thank for tolerating my noobiness.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘template for different pages’ is closed to new replies.
Skip to toolbar