Hello, there was a problem with displaying widgets, registered in a template like this, on the site itself displays only 8 widgets, and they are registered and filled in the admin panel 12 .. 6 on the left and 6 on the right, what could be the problem? Tell me please

if ( function_exists('register_sidebar') ) { $args = array( 'name' => '%d-лево', 'before_widget' => '<div class="sb-bot"><div class="sb-top"> <div class="sb-right"><div class="sb-left"><div class="sb-rb"><div class="sb-lb"><div class="sb-rt"><div class="sb-lt">', 'before_title' => '<h2>', 'after_title' => '</h2>', 'after_widget' => '</div></div></div></div></div></div></div></div>' ); register_sidebars( 6, $args ); } if ( function_exists('register_sidebar') ) { $args = array( 'name' => '%d-право', 'before_widget' => '</div><div id="sidebar-right"><div class="sb-bot"><div class="sb-top"> <div class="sb-right"><div class="sb-left"><div class="sb-rb"><div class="sb-lb"><div class="sb-rt"><div class="sb-lt">', 'before_title' => '<h2>', 'after_title' => '</h2>', 'after_widget' => '</div></div></div></div></div></div></div></div>' ); register_sidebars( 6, $args ); } 

    1 answer 1

    And how do you get sidebars then? I do not see their id in the parameters. In theory, you should set something like 'id' => 'test-sidebar' , and then output the sidebar where you need it with the function dynamic_sidebar('test-sidebar'); .

    For example, the sidebar registration function:

     if (function_exists('register_sidebar')) { register_sidebar( array( 'name' => '1-лево', 'id' => 'test-sidebar', 'before_widget' => '', 'before_title' => '<h2>', 'after_title' => '</h2>', 'after_widget' => '' ) ); } 

    Then, somewhere on the page we display this sidebar with all the widgets that you put into it: dynamic_sidebar('test-sidebar');

    • that is, then you need all 12 sidebars so to display each separately? - Konstantin
    • The first 8 in the list, I separately filled in the admin panel, in the widgets section, as soon as I added something to them, they were displayed on the website, the output was <?php get_sidebar(); ?> <?php get_sidebar(); ?> - Constantine
    • instead of the get_sidebar(); function get_sidebar(); you need the dynamic_sidebar() function, which needs to pass your sidebar id - alenkins
    • Did I understand correctly ? what would then bring out the 12 sidebars I would need to call the function dynamic_sidebar() 12 times? - Konstantin
    • one
      All)) figured out)) thank you very much) in the sidebar.php file sidebar.php were only 8 functions) .. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(8) ) : endif; ?> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(8) ) : endif; ?> - Constantine