Custom Sidebars
By default, Taproot has five built-in widget areas. A “primary” sidebar that is used when selecting a left or right sidebar layout for a page, and 4 “footer” widget areas.
Additional sidebar areas can be added using the default WordPress “register_sidebar” function.
To display your custom sidebar in a particular location, you can use the ‘hybrid/view/sidebar/data’ filter with the required logic to decide which pages to apply your customization to.
<?php
/**
* Define a custom sidebar for post with the id of '123'.
*/
add_filter( 'hybrid/view/sidebar/data', function($data){
if(is_single('123') {
$data['sidebar'] = 'my-custom-sidebar';
}
return $data;
});
If adding to a single post or page, make sure to choose a left or right sidebar layout in the Taproot Page Settings.
Coming Soon: I have been working on a plugin for sidebars that will add the following functionality:
- Create new custom widget areas in the WordPress Widgets admin page.
- Choose the widget area you wish to display on a given post type or on a “per post” basis.
- Define unique colors for each custom sidebar area.