Custom Sidebar for WordPress Theme in 3 Steps

Sidebars allow you display widgets inside your theme. It’s so important for a WordPress based website, You can use a sidebar as you want to show in any location of your theme. It’s so easy to add a custom sidebar. Any theme atleast have 1 Sidebar, Sometimes We need to make a Custom Sidebar. So Let’s start to make this.

Step 1. Open to edit functions.php file

Open functions.php file from activated theme folder from Cpanel or File Explorer, Click right button and click to edit.

Edit functions.php file from cpanel - indetails
Edit functions.php file from cpanel – indetails

Step 2. Find Widget Code of your theme, Copy this Code & Past it bottom of this codes.

Find Widget Codes location of your theme.

Copy on sidebar codes block and Past bottom of the codes

Find Widget codes of your theme

Before Save, Change the text red marked.

register_sidebar( array(
‘name’ => esc_html__( ‘YOUR SIDEBAR NAME AS YOU WANT‘, ‘NO NEED TO CHANGE HERE IF HAVE ON YOUR THEME CODE‘ ),
‘id’ => ‘WRITE AN CUSTOM UNIQUE ID‘,
‘description’ => esc_html__( ‘Add widgets here.’, ‘myshare-pro’ ),
‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2 class=”widget-title”>’,
‘after_title’ => ‘</h2>’,
) );

As Result you can see your Sidebar location in WordPress Widget Menu (http:yourdomain.com/wp-admin/widgets.php)

Your Custom Sidebar will be added - indetails
Your Custom Sidebar will be added – indetails

Step 3. Past the code below where you want to show your Sidebar.

<?php if ( is_active_sidebar( ‘WRITE HERE YOUR CUSTOM SIDEBAR ID‘ ) ) : ?>
<?php dynamic_sidebar( ‘WRITE HERE YOUR CUSTOM SIDEBAR ID‘ ); ?>
<?php endif; ?>

Custom Sidebar in WordPress - indetails.info
Custom Sidebar in WordPress – indetails.info

Now you can see your Custom Widget in Web Page

Custom Sidebar - indetails
Custom Sidebar – indetails

Thank you.

Comment