Issue
I am trying to register multiple sidebars at once and access theme by different id's just like we are registering multiple menus at once i.e. Main-Menu and Footer-menu.
<?php register_nav_menus(array('primary-menu' => 'Main-Menu','secondary-menu' => 'Footer-menu')); ?>
- How we will do this with sidebars as well.We just write one line code and register multiple sidebars at once.
Solution
You need to use the WordPress native function register_sidebars().
You will be able to register multiple sidebars at once as your menus.
register_sidebars( 2, array(
'before_widget' => '<div class="widget %d">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
'name'=>__( 'My sidebar %d', 'textdomain' )
);
The register_sidebar() function is a better way to achieve this but it takes more than 1 line.
Answered By - Benoti Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.