How add more sidebars to site in wordpress?

I am new in WordPress so if my question simple is I apologize. So
I want to add second sidebar to my page. I added one to my page, but when i try to add the second i have the same sidebar as in the first.

How can i add two or more sidebar in wordpress?

Read More

I inserted some examples of my code. File function.php

register_sidebar(
array(
    'name' => 'Program 1',
    'id' => 'program_1',
    'description' => 'module',
    'before_widget' => '<div class="left-sidebar"><ul class="subnav">',
    'after_widget' => '</ul></div>',
    'before_title' => '<div style="display:none !important;">',
    'after_title' => '</div>',
    'class' => 'subnav'
)

);

register_sidebar(
array(
    'name' => 'Program 2',
    'id' => 'program_2',
    'description' => 'Si li ha',
    'before_widget' => '<div class="left-sidebar"><ul class="subnav">',
    'after_widget' => '</ul></div>',
    'before_title' => '<div style="display:none !important;">',
    'after_title' => '</div>',
    'class' => 'subnav'
)

);

File sidebar.php . I thnik probably the solution is in this file. But how to include both sidebars?

<?php if(!dynamic_sidebar('program_1')): ?>
<div class="widget">
    <h2>Programs</h2>
</div>

Thanks more!

Related posts

Leave a Reply

1 comment

  1. The best way to do this is to create a new page template by copying ‘page.php’ to ‘page-sidebar2.php’ and to add the following at the top of the page

    <?php
        /*
          Template name: Page with Sidebar 2
        */
    ?>
    

    In this new template you search for get_sidebar() and edit this to get_sidebar('sidebar2').

    Then as the last step you duplicate sidebar.php to sidebar-sidebar2.php and modify

    <?php if(!dynamic_sidebar('program_1')): ?>

    to

    <?php if(!dynamic_sidebar('program_2')): ?>

    Save all the files and create a new page with the new available template (choose it from the right). It should use the new created sidebar instead of the old one.