Last updated on

BoldGrid themes installed through the Inspirations plugin display the sidebar by default for all blog post and archive pages, but sometimes you want to display the sidebar on other pages as well.  This guide will demonstrate how you can use filters to hook into the theme configuration and get the sidebars to display on pages using the Default Template.

Adding filters to your theme can be accomplished in a number of ways, and the best way to add filters to your website’s theme is to use a plugin, such as Code Snippets. The reason we recommend using a plugin to create new filters instead of editing your theme files directly is that it allows your custom code to persist through theme updates.  Custom modifications to your theme files will be overwritten when you eventually update your theme, unless you are using a child theme or other kind of custom WordPress theme to design your website.

Once you have your preferred code manager installed you can create a new entry with the following snippet:

function show_sidebar ($config) {
    $config['template']['sidebar'] = [
        '[page_home.php]is_page_template',
    ];
    return $config;
}

add_filter( 'boldgrid_theme_framework_config' , 'show_sidebar' );

The sidebar will display automatically on every page, except for those included in the [‘template’][‘sidebar’] array within the theme configuration, and the provided snippet removes the Default page template from that list so your sidebars will on any page that uses it.

 

SIGNUP FOR

BOLDGRID CENTRAL  

   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.

Leave a Reply

Your email address will not be published. Required fields are marked *