Most of the free WordPress themes offer a single sidebar for all pages and posts. Some commercial themes offer custom sidebar option. This option will allow you to create multiple sidebars and assign to different posts based on your need. Don’t worry, if your theme does not offer this option. Here is how you can create different sidebars on different posts in WordPress.
Table of Contents
Why Do You Need Different Sidebar on Different Posts?
When you run a site with large number of categories it does not make sense to show the same sidebar on posts. You may have the following situations:
- Add different sidebar widgets only on certain section of your site.
- Showcase different sidebar based on category
- Show different sidebar on archive pages
- Display different sidebar on custom pages like 404 page
- Show different sidebar on individual post or page based on the need
There are varieties of plugins available on the WordPress repository for creating custom sidebars. But all the above listed needs can be simply fulfilled with a single custom sidebar plugin.
Installing Custom Sidebars Plugin
Go to “Plugins > Add New” and search for “custom sidebar”. Install and activate the “Custom Sidebars – Dynamic Widget Area Manager” plugin from WPMU Dev.
Once activated, the plugin will create additional settings in different places. Let us checkout all options in detail.
Assigning Existing Theme’s Sidebar
Every theme will have a default sidebar which will be assigned to all the posts and pages. In order to replace the existing default sidebar, go to “Appearance > Widgets” section and click on the sidebar (this should be generally default sidebar”. Check the option “Allow this sidebar to be replaced” as shown below:
Click on the “Sidebar Location” and assign the sidebar to required posts. You can assign the sidebar based on the two options:
- On individual posts based on category or post types
- On archives based on types, category or author
This will cover all possible options for you to assign different sidebars on different posts. Basically you don’t need to assign the default sidebar as it will be already assigned to all existing posts, pages and archives of your WordPress site. Ensure you have checked the “Allow this sidebar to be replaced” option to allow the plugin to replace the default sidebar with custom sidebar.
Creating Custom Sidebars
Under “Appearance > Widgets” section, you can see the option called “Sidebars“. Click on the “Create a new sidebar” button.
Enter the name and description for your sidebar.
Note: The option “Advanced – Edit custom wrapper code” will allow you to add custom HTML code to modify the titles and widgets inside the sidebar. You can leave this advanced option without modifying.
Adding Widgets to Custom Sidebars
Once the custom sidebar is created, you can see it beside the theme’s sidebars. Drag and drop the widgets inside the custom sidebar similar to default theme’s sidebar.
Assigning Custom Sidebar
Click on the “Sidebar Location” link to assign the custom sidebar to individual posts. Under “For all Single Entries matching selected criteria” section, select the categories and post types.
The plugin will replace the default sidebar on all posts matching the selected categories and post types with the new custom sidebar. Under “For Archives” section assign the sidebar to archive pages based on the archive type, category and author.
Bulk Change Sidebars
If you already have larger number of posts and pages, the bulk edit option will allow to replace the sidebars on bulk posts and pages in one click. You may be wondering, why this bulk edit option is required when you can assign the sidebar based on category. Let us take an example that you have the category structure and the sidebar assignments like below.
This looks simple as long as one post is assigned only one category. When a single post is assigned to subcategory 1, 2 and 3 then the sidebar will assigned based on the alphabetical order of the category. If you wanted to have different sidebars for those posts with multiple categories then use bulk edit option and assign the required sidebar.
Assign Sidebar in Post Editor
The plugin will add a new metabox called “Sidebars” in WordPress post and page editors. Here you assign the required sidebar to replace the default sidebar right from the editor.
Again, you need to assign the sidebar only if the post is assigned to multiple categories having different sidebars. Otherwise you don’t need to assign here, the default sidebar will be replaced as per the assignments under “Appearance > Widgets” section as explained above. If you don’t see the “Sidebars” metabox in post editor, click on the “Screen Options” on top right corner and select the “Sidebars” checkbox.
Note: Considering full site editing future in WordPress, the developer discontinued Custom Sidebars plugin. However, you can use other plugins like Lightweight Sidebar Manager to create and manage multiple sidebars on your site.