Friday, May 4, 2012

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 ?>             
            
            

No comments:

Post a Comment

If you Satisfied , Please Leave a comment