All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Different sidebar for home and posts page WordPress

  • # February 21, 2010 at 4:44 pm

    Hi guys, I asked this question a month ago or so and I am still stumped. The site I am working on is

    I need to know if anyone can tell me how to make my blog page and home page have different sidebars. For the blog page I want pretty much a standard blog sidebar with categories, tags, and a tag cloud, but I can’t get anything other than the sidebar that is on my homepage.
    If anyone has ever done this successfully and can help me out that would be awesome!

    # February 22, 2010 at 1:40 am

    The home page will use the template "index.php". A post’s page will use "single.php".

    First you need to decide how many types of pages each sidebar will appear on. For example, if the sidebar on the homepage is ONLY going to be seen on the home page (not on a category page, blog page, single page, post page, etc etc) then do the following:

    1. Duplicate your sidebar.php and give it a new name (like, sidebar-home.php).

    2. Open up your index.php and find

    < ?php get_sidebar();?>

    and replace it with

    < ?php include (’sidebar-home.php’); ?>

    3. Open up your sidebar.php and edit it to show what you want on single.php, category.php, etc etc.

    If the sidebar on the homepage is going to be used elsewhere in the site, then you’re going to want to do the opposite of above:

    1. Create a new sidebar.php and give it a new name (like, sidebar-single.php) and edit it to only show what you want to see on a post’s page.

    2. Open up your single.php and find

    < ?php get_sidebar();?>

    and replace it with

    < ?php include (’sidebar-single.php’); ?>

    That was sort of weirded confusingly, but I hope you get the idea.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed