Custom Sidebar Areas & Advanced Management
The total theme includes a very basic function for creating custom sidebar regions which you can then select on a per-page or per-post basis. However, if you want a custom sidebar for a specific section of the site such as an entire post type things would get tedious choosing your custom sidebar every time you add a new post. Another example would be altering the sidebar for specific archives, which don’t have the same ability to select your custom sidebar via a meta option (since an archive isn’t a post). For this reason Total includes a handy filter called “wpex_get_sidebar” which can be used to return a specific sidebar anywhere on the site.
Adding A Custom Sidebar Area
This is very simple, just go to Appearance -> Widgets and use the function to add a new sidebar area.
Selecting Custom Widget Areas Per Page/Post
For simple edits you can select your specific widget area on a per page/post basis via the page settings (see screenshot below) for more advanced edits continue on to the next sections.
Custom Widget Area Per Category/Taxonomy
You can also select your custom widget area for a specific taxonomy/category/tag on your site and this sidebar will be applied to all the posts inside this taxonomy as well as the taxonomy archive itself.
Overriding Main Sidebar With Custom Widget Area
Now you can use the filter “wpex_get_sidebar” to return your new widget area instead of the default sidebar output wherever you want it!
Now that you know your ID here is an example function using the theme filter.
Widget ID added in Total 2.0.0
In Total 2.0.0 you can actually see your sidebar ID right in the widget area box.
Replacing Footer Widgets With Custom Sidebar Areas
So you can see replacing the main sidebar is very simple with the built-in filter, the footer widget areas on the other hand don’t have filters so instead of using the filter “wpex_get_sidebar” you would use the WordPress core filter “sidebars_widgets”. Below is an example:
All Theme Sidebar’s ID’s
Below are all the ID’s of the various custom sidebar areas that may be generated by the theme, so you can actually alter any of those:
- sidebar
- pages_sidebar
- search_sidebar
- portfolio_sidebar
- staff_sidebar
- testimonials_sidebar
- bbpress_sidebar
- footer_one
- footer_two
- footer_three
- footer_four
Displaying A Widget Area In A Template File
If you want to display your custom widget area in a template file it’s really simple. All you need to do is use the WordPress function dynamic_sidebar. Example: