Widgets Development in wordpress

function.php

copy and past in function.php page , you can also development more widgets area using this function

<?php
function add_widgets_init() {

    register_sidebar( array(
        
'id' => 'first-sidebar',
        
'name' => __'First Sidebar' 'buttercream' ),
        
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        
'after_widget' => '</aside>',
        
'before_title' => '<h2 class="widget-title">',
        
'after_title' => '</h2>'
        
)
    );

    register_sidebar( array(
        
'id' => 'second-sidebar',
        
'name' => __'Second Sidebar' 'buttercream' ),
        
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        
'after_widget' => '</aside>',
        
'before_title' => '<h2 class="widget-title">',
        
'after_title' => '</h2>'
        
)
    );

    register_sidebar( array(
        
'id' => 'third-sidebar',
        
'name' => __'Third Sidebar' 'buttercream' ),
        
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        
'after_widget' => '</aside>',
        
'before_title' => '<h2 class="widget-title">',
        
'after_title' => '</h2>'
        
)
    );
}
add_action'widgets_init''add_widgets_init' );  // initilization
?>

sidebar.php

copy and paste in sidebar.php page or any where you want to see your widgets

<?php do_action'before_sidebar' ); ?> 
 <?php if ( ! dynamic_sidebar__'First Sidebar' 'buttercream' ) ) ) : ?> 
<?php endif; // end First sidebar widget area ?>             
  



<?php do_action'before_sidebar' ); ?> 
<?php if ( ! dynamic_sidebar__'second-sidebar' 'buttercream' ) ) ) : ?>  
<?php endif; // end second sidebar widget area ?>        
     
            
 <?php do_action'before_sidebar' ); ?>  

<?php if ( ! dynamic_sidebar__'Third Sidebar' 'buttercream' ) ) ) : ?> 
<?php endif; // end third sidebar widget area ?>             
            
            

Advertisements

One thought on “Widgets Development in wordpress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s