WordPress: Creating Multiple Sidebars

WordPress: Creating Multiple Sidebars

WordPress is by far the easiest CMS to customize, but there are often times when the default installation and your chosen themes options just dont offer the flexibility that you need. Luckily for us WordPress has a massive community of dedicated developers willing to help us iron out these issues by creating some amazing plugins.

When setting up wpsquared.com I knew I wanted multiple sidebars, but my inital plan was to create multiple page templates, and registering new sidebars to achieve this; an idea I soon realised would not offer me (and the other writers) the flexibility we craved – even if it would be tidier.

Why Would You Want Multiple Sidebars?

Im sure that there are many reasons why a blog owner would want to show different sidebar content to those visiting differnt areas of their site, but for us it was primarily an advertising concern. It makes sense to show targetted advertisements that would depend primarily on what content they are viewing, we could also show other relevant articles to them using the same methodology and therefore hopefully keep there attention longer than we may have if showing unrelated content.

Before deciding on which plugin we were going to use I decided to test 3 plugins in total and have documented my findings below. All the plugins tested were free, and available through the WordPress plugin repository – though premium plugins do also exist.

Multiple Sidebars Plugin – [rating=5]

Requires: 3.0 or higher, Compatible up to: 3.3.2, Last Updated: 2012-3-10, Downloads: 6,890 – (at time of writing)

Multiple Sidebars Plugin

The main reason I wanted to test this plugin before testing any others was purely based on the fact that it has been recently updated, even if it has very few ratings from the WordPress community.

Installation of the plugin is simple, but the configuration certainly takes at least a few minutes to get your head around.

The first thing to do is add the multiple sidebars widget into your themes standard sidebar widgetized area, as seen in the image below, then add the widgets you wish to act as the default sidebar to the widgetized area named “Default”.

To set your homepage sidebar & widgets visit the “options” page in the WordPress dashboard under “Sidebars” and set your homepage sidebar (in our case this is the default sidebar) to active.

To create alternative sidebars, and to set sidebars on a per page, or post basis simply visit a page or post that you are editing & set the paramaters you want – as per the image below (the only diffence is that the installed plugin is in english).

To create a new sidebar simply click + and enter the name of your sidebar, then set up the widget options under “appearance” in the WordPress dashboard. You can then select the sidebar on each and every page you wish it to be displayed instead of the default sidebar.

Widget Logic Plugin – [rating=3]

Requires: 2.8 or higher, Compatible up to: 3.3.2, Last Updated: 2012-5-1, Downloads: 407,682 – (at time of writing)

The second plugin I decided to test was Widget Logic. I have read a number of good things about this plugin, and as with the Multiple Sidebars plugin it is updated often.

To be honest, I expected more from this plugin. My initial feeling towards it is that it over complicates what you want to be as simple a process as possible.

To use the plugin you have to enter conditional tags to the widget logic text area added to your widgets, some examples of conditional tags that you may wish to use are as follows:

Examples

  • is_home() — just the main blog page
  • !is_page('about') — everywhere EXCEPT this specific WP ‘page’
  • !is_user_logged_in() — shown when a user is not logged in
  • is_category(array(5,9,10,11)) — category page of one of the given category IDs
  • is_single() && in_category('baked-goods') — single post that’s in the category with this slug
  • current_user_can('level_10') — admin only widget
  • strpos($_SERVER['HTTP_REFERER'], "google.com")!=false — widget to show when clicked through from a google search
  • is_category() && in_array($cat, get_term_children( 5, 'category')) — category page that’s a descendent of category 5
  • global $post; return (in_array(77,get_post_ancestors($post))); — WP page that is a child of page 77
  • global $post; return (is_page('home') || ($post->post_parent=="13")); — home page OR the page that’s a child of page 13

 

Content Aware Sidebars Plugin – [rating=6]

Requires: 3.1 or higher, Compatible up to: 3.4.2, Last Updated: 2012-10-8, Downloads: 21,248 – (at time of writing)

I have to admit that by my 3rd test was not expecting to find a plugin that was going to beat the Multiple Sidebars plugin that was tested first, but I was very wrong.

While the Content Aware Sidebars plugin may not win hands down, for my purpose, and I am sure for most peoples purpose this plugin will prove to be the easiest to configure and use on an ongoing basis. I am specifically pleased at the simplicity of setting up category sidebars that do not have to be set for each individual post – just configure once and let the plugin do the rest.

Unlike the Multiple Sidebars Plugin I dont beleive an explanation of how the plugin works is required, it is quite self explanatory for anyone that is used to configuring and using any WordPress plugins. But, here are some screenshots of the plugins administration panel for you to look at.

Creating new sidebars & choosing conditional settings.

List of sidebar templates (as seen from admin)