Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Register the sidebars in your functions.php
file.
/**
* ----------------------------------------
* Widgets
* ----------------------------------------
*/
add_action( 'widgets_init', 'init_theme_widgets' );
function init_theme_widgets()
{
register_sidebar([
'name' => __( 'Sidebar One'),
'id' => 'sidebar-1',
'description' => __('Sidebar One allows you to include widgets!'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
]);
register_sidebar([
'name' => __( 'Sidebar Two'),
'id' => 'sidebar-2',
'description' => __('Sidebar Two allows you to include widgets!'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
]);
}
Check for the sidebars, in your templates, use it with conditionals if you need to as well.
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div class="sidebar-1">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div class="sidebar-2">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div>
<?php endif; ?>