Loading…

How to add custom dynamic sidebars in WordPress?

A Sidebar in WordPress is an area where widgets can be used with a theme and this area is also termed as a Widgetized area. In WordPress, sidebar is created by using a function named as register_sidebar() function. The widget zed area should be registered in WordPress supported the theme as they are presentational. The sidebar function takes only one argument of an associative array of parameters that set the options for the widget area. Wrap $args array and register_sidebar() both are separate functions that can be called on ‘widgets_init’ hooks. In short, with the use of register_sidebar() method/ function users can add sidebars to WordPress. Syntax code for the creation of sidebar-

$args = array(
   'name' => __( 'Sidebar name', 'theme_text_domain' ),
   'id' => 'unique-sidebar-id',
   'description' => '',
   'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">',
   'after_widget' => '</li>',
   'before_title' => '<h2 class="widgettitle">',
   'after_title' => '</h2>'

);

Suggest An Answer

No suggestions avaliable!

Latest post from WordPress Interview Questions

Ask Question