Register your Custom Sidebar


To register your own custom sidebar in wordpress, you just need to write the following code inside “twentytwelve_widgets_init()” function which is present in functions.php in your theme folder.

register_sidebar( array(
 'name' => __( 'your sidebar name', 'twentytwelve' ),
 'id' => 'sidebar-4',    // must be unique 
 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),
 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 'after_widget' => '</aside>',
 'before_title' => '<h3 class="widget-title">',
 'after_title' => '</h3>',
 ) );

after adding this code in your functions.php, go to your admin panel and you will get your custom sidebar.

To call your sidebar inside your template file just write the following code.

<?php dynamic_sidebar( 'sidebar-4' ); ?>
Advertisements