LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress Tips » How To Create A Widget Area In WordPress Template Or Themes?

How To Create A Widget Area In WordPress Template Or Themes?

How-To-Create-A-Widget-Area-In-WordPress-Template-Or-Themes
If you ever used any premium WordPress theme then you have got this widget in your post editor sidebar as then have already added it into there theme. But if you are designing your own WordPress theme from scratch then you will not get widgets section in your WordPress sidebar.

So don’t worry as here we have a little code through following you will be able to see add widgets option in your WordPress theme. For this you just have to edit your function.php and that php file where you want to add widgets section. Rest you have nothing to edit more anytime.

How To Create A Widget Area In WordPress?
Step 1:) Open Appearance > Editor file in your WordPress dashboard.
Step 2:) Open your Theme Function (function.php) file from the list of your theme file.
Step 3:) Copy the below code and Paste it in the end of function.php file.

/* ------------------------------------------------------------------------- *
 * Right Sidebar Widget Area
/* ------------------------------------------------------------------------- */
function exeideas_widgets_init() {
 register_sidebar( array(
 'name' => 'Right Sidebar Widgets',
 'id' => 'sidebar_widgets',
 'description' => 'Add Your Desired Widgets Here',
 'before_widget' => '<div class="widget">',
 'after_widget' => '</div>',
 'before_title' => '<h2>',
 'after_title' => '</h2>'
 ) );
}
add_action( 'widgets_init', 'exeideas_widgets_init' );

Step 4:) Update file.
Step 5:) Now go to that PHP theme file where you want to show widgets section like sidebar, header, footer etc…
Step 6:) Now Copy the below code and Paste it in the sidebar.php, header.php, footer.php etc file.

<!-- Widget Area -->
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar_widgets') ) : ?>
<?php endif; ?>
<!-- Widget Area -->

Step 7:) Save and done.

Recommended For You:
How To Clear/Reset Your Full WordPress Blog To New One?

Table of Contents

Customization:

You nothing have to edit any extra things in it. You just can edit sidebar_widgets with your desired widget section ID to add CSS later on whole widget section. Also edit widget with your own class to add CSS on every widget. If you want to change name of widget area that will be visible to admin only, you can change from Right Sidebar Widgets.

Can I Add More Widget Area In A Theme?

Yes, you can add unlimited widget area in your theme, just follow all the step again and again and must change name at Right Sidebar Widgets for every widget code in function.php and also widget ID at sidebar_widgets.

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

Recommended For You:
Cleaning The Negative SEO Attack With Ahrefs

You Like It, Please Share This Recipe With Your Friends Using...

2 Responses to “How To Create A Widget Area In WordPress Template Or Themes?”

  1. Faheem Ahmed says:

    Thank you so much for such an informative knowledge.

Leave a Reply to Faheem Ahmed Cancel reply

Your email address will not be published. Required fields are marked *