26 Oct 2007

I realized that I didn’t clarify how to do this very well. Sorry. Anyhoo… For single pages, you’ll want to use the following but change the name for each sidebar page you want to be different. So if you have different sidebar content for you about page and your portfolio page this is how it would look:

  1. < ?php if (is_page(about)) { ?>
  2. < ?php if (is_page(portfolio)) { ?>

I learned today how to use one sidebar page for multiple pages with different sidebar content for each page. It may come easy to most of you but for me it was a great revelation. It’s fairly simple to do and why I hadn’t learned it before now is beyond me. I guess some days things just click.

Anyway, if you use Wordpress as a CMS (which I encourage anyone to do) these are the steps for having multiple sidebar content in one sidebar page (sidebar.php).

This method is only for using a static homepage and a static blog page

For the static Blog Page

  1. < ?php if (is_home()) { ?>
  2. CONTENT GOES HERE
  3. < ?php } ?>

For Single Pages

  1. < ?php if (is_page(about)) { ?>
  2. CONTENT GOES HERE
  3. < ?php } ?>

It’s that simple and the content you want for each individual page shows up only on that page. I can’t believe I’ve been missing out on this all this time.

5 Comments

  1. No. 1 Pop Stalin 01/01/08

    @Jeromy: I’d guess that if you’d need different content for each sub-page, it would work just as it does above. I personally rather have one rather large file, than dozens of template files.

  2. No. 2 Jeromy 12/23/07

    Any idea how to accomplish this with subpages as well? LIke if I want a sidebar to show on About Us and all it’s subpages? THAT would be huge

  3. No. 3 Pop Stalin 12/20/07

    @Sparkybarkalot : Very nice. Most of the clients I do work for have static sidebars, so my solution works for me but I’ll have to keep the other one linked for clients who are more hands on.

  4. No. 4 Sparkybarkalot 12/06/07

    Your idea works, but I wanted something more “client friendly” for a site that had multiple static pages. Found this:

    http://www.noscope.com/journal/2005/05/pages-with-editable-sidebars

    Trying it now, but looks more promising than your (very nice and very workable) solution

  5. No. 5 Nick 10/26/07

    As a helpful hint, I think it should be stated that you’ll want to replace the red text that is your post slug with the post slug within quotes. That is, you would do something like this:

    I don’t know if that was made clear enough in your post for most designers to catch on. Great post, though, and thanks for the quick tips.

Tell Me What You Think

About Me

My name’s Jen; I’m a cynical, sarcastic, ex-drummer who is fond of dark humor. I've held way too many factory & retail jobs but finally found my calling one Christmas holiday in a dark, musty basement. I am now a CSS & XHTML web standards looney and can be found daily—when I’m not at my Mac—at the local fair-trade coffee shop buying an iced-soy mocha no matter the temperature.

I am also the owner of Pop Stalin Design specializing in CSS & XHTML web design as well as custom WordPress themes.