Over the years developing WordPress themes, I have worked with many designs that require a different sidebar for just about every page on the site. While it has been possible to accomplish this using a combination of PHP if/else statements, Widget Logic, Widget Context, or other plugins, I have yet to find a decent solution for managing sidebars on a page-by-page basis. Since many of the sites I now work on require this functionality, I decided it was time to write a rather simple but effective plugin that handles this. Therefore, I’m introducing Unique Page Sidebars.
There are obviously some limitations to this plugin, and I don’t expect me to use it on every site I develop, but I chose the most common use-case I have for needing dynamic sidebars, and developed this plugin to fit that need. That said, here is a list of features:
- Creating an unlimited number of sidebars, each with customizable names, descriptions and before/after title/widget tags (see options of register_sidebar() on the WordPress codex)
- Mapping any of the created sidebars to anywhere from 1 to unlimited number of pages
- Only one line of code needed in your theme
- Can easily default to a default sidebar
However, there are a few drawbacks (some of which I’m looking to working out in subsequent versions):
- Only one sidebar per-page
- No ‘default’ options for new sidebars
Installation
To install, download the .zip, unpack it and upload to your WordPress installation in /wp-content/plugins/. Log in to the admin backend and activate it on the Plugins page. You should now see another menu item under “Appearance” called “Manage Sidebars” which will be where you can manage all of the sidebars.
In your theme, all you need to add is the following line where you would like the dynamic sidebar to show up:
<?php dynamic_sidebar( apply_filters( 'ryno_sidebar', 'default-sidebar-id' ) ); ?>
In the above snippet of code, ‘default-sidebar-id’ is simply the ID for your default sidebar which you should define in your functions.php file using register_sidebar().
Screenshots
Here are a couple screenshots of the sidebar management screen:
Download
Download a copy on WordPress.org!
Current version: 0.1 (December 21, 2011)


If you could extend this functionality for posts as well as pages, I’d give you a hug…
I’ll hopefully be working on that in the next version.
This is the plug in I’ve been waiting for…. please try and keep it muppet-friendly,
cheers
Hey Andrew -
Thanks for this plug-in. I am having problems using it on my page, I am not that educated in code. do i need to worry about any code other than on the page I would like the custom sidecar to appear?
I guess the “register_sidebar()” is throwing me off.
Thanks -
James
You shouldn’t really have to worry about any of the register_sidebar() code. In your functions.php if you find where register_sidebar() is defined, you can use one of those ID’s for the default sidebar to show up. Otherwise if you replace ‘default-sidebar-id’ with NULL (no quotes around it), nothing should show up by default.
Just place the dynamic_sidebar() in your sidebar.php file (or another file if you want) where you want the sidebar to show up.
Whenever I get around to updating the plugin, the need for editing code should go away.
sorry I am still very confused about where and what exactly to put in the code. Can you give a specific example?
In your theme you should have a file called sidebar.php that is already there. You should copy and paste this code into it wherever you would like it to show up.
< ?php dynamic_sidebar( apply_filters( 'ryno_sidebar', NULL ) ); ?>
I think I’m going to sit down and force myself this week to rewrite this to make it so you don’t have to touch any code. I’ve had it in my head for weeks but haven’t been able to get an update out.
If you have any troubles and need more help with this until then, feel free to email me (andrewryno@gmail.com).