Tuesday, 14 August 2012

How to call widget in our site in wordpress

Step 1 : Create one sidebar in sidebars file.

<?php
register_sidebar(array(
        'name'=>'moreWidgets',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ));
?>

Step 2: Goto admin section and list out widget there. one sidebar is created with name moreWidgets. Drag any widget in that sidebar.

Step 3 : put this code in anywhere in your site....Widget functionality work there.....
<?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('moreWidgets') ) :
        endif;
?>

1 comment:

  1. Great Tutorial For Widgets for Wordpress. Nice Work....

    ReplyDelete