Register Sidebar In WordPress

WordPress is very easy to customize as per the user need. One of the way of making it versatile is by creating the sidebar areas. For that, first of all what we have to do is we have to register sidebar in WordPress first and then after that, display it in the front-end, to the visitors who visits your site.

Now, since you already know that you can create the sidebar area for your site via WordPress, hence, now you might be eager to know about this, right? Well, for that, here, we will be discussing about how to register sidebar in WordPress and display it in the front-end.

For registering the sidebar area in WordPress, first of all what you have to do is, you have to register the sidebar area as below:

function theme_widgets_init() {
'name' => esc_html__('Sidebar', 'textdomain'),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
add_action('widgets_init', 'theme_widgets_init');

Here, in the above code, what we have done is, we have created the function named as theme_widgets_init, in which we have registered the sidebar area using the WordPress default function register_sidebar to register the sidebar areas in WordPress.

Now, the only thing remaining for the sidebar creation is that, you need to add the created function to the widgets_init hook, which is WordPress default function to add the sidebar areas and display it in the widget sections area, ie, in Appearance->Widgets section, since only creating the sidebar area is not enough and proper way.

Now, after all of the above steps has been completed, you can display the registered sidebar area in any place as required through your theme file. Here, the code to display the registered sidebar in the front-end is provided below:

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

Here, in the above code, the function dynamic_sidebar is the default function to display the sidebar in the front-end provided that here you need to provide the unique id when you used to register the sidebar area.


The above image shows that the sidebar area has been registered and we have also added the Calendar widget in that area too. Now, if you have added the code in the theme files as described above for displaying it in the front-end, then, it is going to look similar to this one as added to this sidebar area:


Now, if you are able to register sidebar in WordPress, and then display it in the front-end following the above tutorial, we can assume that you are now more familiar with this than ever before. But, if you are still confused about this and want more help on this, then, do let us know by commenting on the comment box below and we will follow it up.

Post navigation

Bishal Napit

Bishal Napit is a WordPress theme developer from Tansen, Palpa, with a passion to learn more on WordPress.

2 thoughts on “Register Sidebar In WordPress

  1. Thanks for putting this together. So amazingly simple when you know how ?

    Couple of quick questions / clarification:

    1. Does this work with the current version of WP (4.1.1) then?
    2. Does this only work for multiuser or for single install too?
    3. Do you have a demo of the registration page?

    All the best.

    1. Here are the clarification on your doubts:

      1. As of current, the current version of WordPress is 4.8.1, and the same will work with this version of WordPress too.
      2. It will be available for both in multisite installs of WordPress as well as on single WordPress install.
      3. There is not any demo of the registration page available for the sidebar widgets.


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.