Create a Custom WordPress Sidebar in 2 Steps

Hello friends,
Today here we will learn to implement a custom sidebar into WordPress. It is very useful for any WordPress developer while he/she is using the plugins. Whenever we have to put any plugin on to the specific position on WordPress page, then we have to make a sidebar for that particular position.

There is a very simple technique to make a custom sidebar in WordPress.

1)  In the first step you will have to register your sidebar in to the function.php file as below:

 register_sidebar( array(
          'name' => __( 'Sidebar Name', 'Current activated theme name' ),
           'id' => 'sidebar-1',
           'before_widget' => '<aside id="%1$s" class="widget %2$s">',
           'after_widget' => "</aside>",
           'before_title' => '<h2 class="widget-title">',
           'after_title' => '</h2>',
) );

In this code you will have to enter your custom sidebar name and the name of the theme which is currently activated.

2) In the second step you have to just put the sidebar code in the specific file for the position where you want to put the widget (plugin).

Suppose that if I want to create a sidebar for the footer position than we have to put this code into the footer.php file as below:

          <!--?php if ( !dynamic_sidebar('sidebar-1') ) { ?-->
                    This Content is Dynamic Sidebar 1
          <!--?php } ?-->

In the above code you have to just pass your sidebar id to put that sidebar on the footer position.

Now you can see the newly created sidebar in to the WordPress admin side in the Appearance->Widget menu. Then you will have to just drag and drop any widget (plugin) to put any widget on that (here on footer) position.

I wish that this technique will help you to make a custom sidebar in WordPress. Enjoy

Speak Your Mind

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: