WordPress.org

Ready to get started?Download WordPress

Forums

Adding multiple widget areas (far left, far right, after menu bar) (3 posts)

  1. cpisar
    Member
    Posted 1 year ago #

    I am running the most current version of WordPress and using the Parament theme with a few minor adjustments. I am wanting to add widget areas (1 to the far left outside the container, 1 to the far right outside of the sidebar and 1 between the menu bar and container. I am not a complete novice but have been trying to do this for a while and cant seem to get it right. If someone could please help me with the code and where to put it that would be greatly appreciated. Let me know if you need any other information.

    Website: Middlebrooksbasketball.com

  2. drewry
    Member
    Posted 1 year ago #

    You need to add a dynamic sidebar to create a widget area. This is described in codex here. There are two steps to this process. First you need to register the sidebar, which you can find in that theme's functions.php file. In that theme it is line 180 where you see the function titled parament_register_sidebars. Looks something like this:

    function parament_register_sidebars() {
    	register_sidebar( array(
    		'name'          => __( 'Primary Sidebar', 'parament' ),
    		'id'            => 'sidebar-1',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</li>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );
    }

    To create another dynamic sidebar you need to copy the register_sidebar code and just rename your parameters. Then the second step is calling the sidebar by checking first if your sidebar is_active_sidebar and then calling dynamic_sidebar where the parameter you are passing is the 'id' of the sidebar you registered. You can do this as many times as you want.

  3. cpisar
    Member
    Posted 1 year ago #

    I have already added the dynamic sidebar coding in functions.php so I can see the widget area in my WordPress dashboard. I have also added the necessary coding in sidebar.php. I still have the same two problems: 1. I don't know how/where to assign size and placement of each sidebar/widget within the coding. 2. When I place something inside either of the sidebars I have created they aren't showing up on my website. Thanks again for the help.

Topic Closed

This topic has been closed to new replies.

About this Topic