WordPress Custom Sidebar
03/10/2023
The register_sidebar()
function is used to create a custom sidebar in WordPress.
To access the created Sidebars: Appearance > Components in the WordPress panel.
register_sidebar() Code
register_sidebar(
array(
'name' => __('Example Sidebar', 'example-sidebar'),
'id' => 'example_sidebar',
'description' => '',
'class' => '',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
'before_sidebar' => '',
'after_sidebar' => '',
'show_in_rest' => false
)
);
register_sidebar Parameters
- name
Creates the name of the Sidebar in the panel.
- id
The unique identifier id is used to call the sidebar.
- description
It is the description area under the Sidebar in the Widgets section of the WordPress panel. The default value is blank.
Displaying Sidebar Output on the Page
if (is_active_sidebar('example_sidebar')) : dynamic_sidebar('example_sidebar'); endif;