How To Register Sidebars In WordPress

Looking to register a WordPress sidebar in your themes? All you may need is to add some functions to your WordPress theme’s functions.php file.

Registering a WordPress sidebar

To register a sidebar in WordPress, you must add the function below into your functions.php file.

  1. Navigate to Appearance > Editor > Theme Functions from your WordPress Dashboard;
  2. Copy and paste in the code from below;
  3. Click Update File to save the changes.
function custom_sidebars() {
   'id' => 'sidebar',
   'name' =>'Sidebar',
   'description' =>'Sidebar for website.'

add_action( 'init', 'custom_sidebars' );

Calling the sidebar function

To use your registered sidebar, you must use the function below to output the result.

<?php dynamic_sidebar( 'sidebar' ); ?>

Using a WordPress sidebar

To use the WordPress sidebar after calling the function from the step above, you must follow the steps below.

  1. Navigate to Appearance > Widgets;
  2. Drag and drop your widgets into your registered sidebar.