WordPress.org

Ready to get started?Download WordPress

Forums

template for different pages (3 posts)

  1. nimmo
    Member
    Posted 6 years ago #

    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.

  2. Chris_K
    Member
    Posted 6 years ago #

    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 } ?>
  3. nimmo
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic