Multiple dynamic sidebars
09.03.2011
Don't know how to create multiple dynamic sidebars in wordpress? There is a very simple way.

Editing the functions.php file Adding the following code...
‹?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=›'sidebar1',
'before_widget' =› '', 'after_widget' =› '',
'before_title' =› '‹h4›', 'after_title' =› '‹/h4›', ));
register_sidebar(array('name'=›'sidebar2',
'before_widget' =› '', 'after_widget' =› '',
'before_title' =› '‹h4›', 'after_title' =› '‹/h4›', ));
?›
Adding dynamic sidebars. Usually in the sidebar.php file or in extreme cases index.php or in places where we want dynamic sidebars to be displayed, we paste the appropriate code.
1 dynamic sidebar:
‹?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar1') ) : ?›
<?php endif; ?›
2 dynamic sidebar:
‹?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar2') ) : ?›
<?php endif; ?
See the result in the figure above.
By this principle, you can add as many sidebar blocks as you like.
SUBSCRIBE TO NEWSLETTER
Last in our blog
Internet Marketing
04.11.2019
Internet Marketing
03.10.2019