WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Twenty Eleven extra widget area (7 posts)

  1. zeaks
    Member
    Posted 2 years ago #

    I'm trying to add another sidebar widget area under the main one in Twenty Eleven. I'm not sure if I've done it right, but it seems to work. The only issue so far is in appearance > widgets it shows up at the top of the list, when I want it to display as the second one on the list.

    This is how I did it in case that info is needed. I made a copy of sidebar.php and renamed it to sidebar-extra.php then changed
    <?php if ( ! dynamic_sidebar( 'sidebar-6' ) ) : ?> in it, which is the name of my widget area.

    I added the sidebar call to index.php
    <?php get_sidebar( 'extra' ); ?>

    And in my functions I added

    register_sidebar( array(
    		'name' => __( 'Sidebar area two', 'child-theme' ),
    		'id' => 'sidebar-6',
    		'description' => __( 'An optional widget area for your sidebar', 'child-theme' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget' => "</aside>",
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );

    Is there something I can add to this to put it in the proper position in widget options?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues.

    Create a child theme for your customisations. Once your child theme is active, we should be able to help with the customisation.

  3. zeaks
    Member
    Posted 2 years ago #

    @esmi sorry, I am using a child theme, not editing the parent theme.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    The order in which the widget areas are shown is dictated simply by the order that they appear in the functions.php file. Since your child's functions.php is called before the parent's, any widget area you add will always be at the top of the list. To the best of my knowledge, there's currently no way around this issue.

    If it's not been mooted on http://wordpress.org/extend/ideas/ (and I can't find it if it has) it might be worth suggesting some sort of dynamic sidebar priority or ordering option as a new feature. As we see more & more child theme development, I think this would be a nice addition. I'd vote for it.

  5. zeaks
    Member
    Posted 2 years ago #

    Thanks for the info.

    If I could even rename the first default widget area to something else, that would be fine.

    Or

    Is there anyway to remove the function, then re-add it including the extra widget area, then position it that way in the child theme?

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    You could un-register all of the Twenty Eleven sidebars and then re-register them in your child's functions.php file in the correct order.

  7. zeaks
    Member
    Posted 2 years ago #

    Thanks, i'll try that.

Topic Closed

This topic has been closed to new replies.

About this Topic