I’m going to show you how to add custom sidebars to your theme without using any plugins.This is easiest way to add sidebars to your theme.Default in the wordpress theme there is one or two sidebar.In here I’m using a default theme of wordpress named “Twenty Twelve”. There are few steps you have to do.
Step-1 : Register the sidebar
First you must register the sidebar in to theme function page.
Location is wp-content/themes/youtheme
Add the following code to the (end of the page is better) functions.php file in your theme.
if ( function_exists('register_sidebar') )
'name' => __( 'My Custom Sidebar'),
'id' => 'my-custom-sidebar',
'description' => __( 'An optional widget area for your site footer' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
After added and save the functions.php file you can see them from Appearance -> Widgets.
Step-2 : Add the sidebar into the theme to display it
Now you have to do display the sidebar in to your site front-end.To do this add the following conditional tag in to your theme. Normally the sidebar is located in the sidebar.php file in the theme.this file name may be change and depending it according to your theme called.If you need to display this in another individual page you can add this that your page relevant position.
In here I’ll add this to sidebar.php file.
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('My Custom Sidebar')) : ?>
<?php dynamic_sidebar( 'My Custom Sidebar' ); ?>
<?php endif; ?>
In the above php code, you must put your sidebar name by replacing the “My Custom Sidebar”.
That’s only.If not displaying the sidebar you can add widgets to new sidebar and save it and check the front-end.
You can put unlimited sidebars by registering sidebar into function.php file and add display script into sidebar.php or individual pages such as page.php,single.php,home-page.php,index.php,…. with correct positions.