Skip to Content

WordPress: how to have different sidebars on static front page

After setting up a Wordpess static front page with its own template the other day, I decided I didn’t want everything in the sidebars to show on that front page. I looked for conditional code to wrap around the items I wanted to hide, but that didn’t seem like the cleanest solution. Then I wondered: if you can make a separate template for the static homepage, why can’t you make a separate sidebar (or pair of sidebars) and call them from within that static homepage template? Turns out you can.

These instructions are for a three column (two sidebars, one content) layout. If you have just one sidebar, you can skip a step. If you have more than three, you can repeat it.

  • Create a new template for your static page (see above link).
  • Create your new sidebar template files in your theme directory. Copy and paste what you want from your usual sidebars into these, deleting or adding in whatever you want to show up on pages using your new static page template.
  • Go into your static page template. This will vary a bit from one theme to the next, but:

Find this code in your template:

<?php get_sidebar(); ?>

Replace with:

<?php include(“sidebar2.php”); ?>

(replace “sidebar2.php” with whatever you named your sidebar theme file. Leave the quotes intact)

For the second sidebar, you need to find a line in the template that’s something like this:

<?php include (TEMPLATEPATH . ‘/sidebarleft.php’); ?>

and change it to

<?php include (TEMPLATEPATH . ‘/sidebarleft2.php’); ?>

(in which “sidebarleft2” is the name of your second new sidebar template)