How do I add a new sidebar (widgetized area)

Creating new sidebars

You can create sidebars in two different ways. The first is by inserting custom code directly in your functions.php file. The second is by using a Plugin to create the sidebars for you.

Via code

Step 1: Create a child theme

To prevent losing any changes (including the sidebar) when updating your theme create and activate a child theme as described here.

Step 2: Register the new sidebar

Create a new file named ‘functions.php’ in the child theme’s directory.

Note: if you already have a child theme and a functions.php file in the child theme, just add/merge the code below.
Add the following code to the child theme’s ‘functions.php’ file which you just created:

<?php
add_action( 'widgets_init', 'ci_register_sidebar' );

function ci_register_sidebar(){
 register_sidebar(array(
 'name' => 'My new sidebar',
 'id' => 'your-sidebar-id',
 'description' => 'My sidebar description',
 'before_widget' => '<aside id="%1$s" class="widget group %2$s">',
 'after_widget' => '</aside>',
 'before_title' => '<h3 class="widget-title">',
 'after_title' => '</h3>',
 ));
}

You can clone the register_sidebar function inside the ci_register_sidebar one as many times as the sidebars you need to register, by changing the name, id and description each time.

CAUTION: If your functions.php file already exists and has code in it, do not add the <?php line, just continue with the rest of the code. If it’s empty, go ahead and add the <?php on top.

Step 3: Add the new sidebar inside your files

Copy over to the child theme’s folder the file in which you want to add the new sidebar. Edit it and wherever you wish to display the widgets add this code

<?php dynamic_sidebar( 'your-sidebar-id' ); ?>

In the code above make sure you replace the ‘your-sidebar-id’ bit with the unique id you assigned to the sidebar when creating it earlier.

Step 4: Adding your widgets

Navigate to Appearance Widgets and locate the new Widget area you have just created and add widgets to it.Sometimes you will still need to

make some minor css adjustments in order to adapt your new sidebar to the looks of your theme.
Feel free to contact us in our support forums for additional guidance.

 

Via a plugin

Creating a Custom Sidebar

You can use any Custom Sidebar Plugins you wish. But we will check the quite popular WooSidebars plugin.

When you are finished downloading and installing the free plugin, head over to Appearance Widget Areas in your WordPress admin area. Then click on the Add New (1) button to create a new sidebar.

In the New Widget Areas Section fill your sidebar Name (2) and Description(3). Next we are going to select where our new sidebar is going to render. We can render it in a custom post type, page, post etc.Next, Click on the Advanced tab(4) button to view all possible options and places we can render our new widget area. In this example we are going to apply it in “Each Individual Post” and replace our Blog Sidebar in the Sidebar to Replace(6) section.
Finally Click on Save(7) and your new sidebar is ready.

Head over to AppearanceWidgets and add some widgets in your new Widget Sidebar (8)

Check on more WooSidebars  features over at the official documentation page 

No votes yet.
Please wait...

Pssst. We are on Themeforest too! Check out our exclusive themes.

Use the coupon code WORDPRESS and get 30% OFF! Join Today!