WordPress.org

Ready to get started?Download WordPress

Forums

register_sidebar before_widget and after_widget output is wrong (5 posts)

  1. robertjakobson
    Member
    Posted 2 years ago #

    Here is the problem, before_widget and after_widget outputs get placed before and after the complete sidebar section and not before and after the widgets.

    The following code, in the functions file:

    if (function_exists('register_sidebar')) { register_sidebar(array(
      'name' => __( 'Modules' ),
      'id' => 'aside-modules',
      'description' => __( 'Place modules here.' ),
      'before_widget' => '<section>',
      'after_widget' => '</section',
      'before_title' => '<h2>',
      'after_title' => '</h2>'
    ));
    }

    gives me the mark-up of

    <aside>
    <section>
    <h2></h2>
    <ul><li></li></ul>
    <h2></h2>
    <ul><li></li></ul>
    </section>
    </aside>

    However, the output should be:

    <aside>
    <section>
    <h2></h2>
    <ul><li></li></ul>
    </section>
    <section>
    <h2></h2>
    <ul><li></li></ul>
    </section>
    </aside>
  2. styledev
    Member
    Posted 1 year ago #

    I am having this exact same issue. It is very odd. Anyone else out there have any ideas?

  3. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    This has worked well for me to add a custom widget area anywhere desired in a page template:

    http://www.transformationpowertools.com/wordpress/add-custom-widget-area-wordpress

  4. styledev
    Member
    Posted 1 year ago #

    I actually figured out that I was passing the before and after wrong.

  5. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    FYI, an error is present in first code above

    'after_widget' => '</section',

    should be

    after_widget' => '</section'>,

    missing closing >

    (not that the whole code is verified)

Topic Closed

This topic has been closed to new replies.

About this Topic