• Hi all,

    I got some problem when trying to add custom html tag for dynamic sidebar.

    the desired result is :

    <div class="custom">
       <h2>Widget title</h2>
       <div class="custom-wrapper"> <!-- this is the problem -->
        some widget content .....
       </div>
      </div>

    I tried to use :

    register_sidebar( array(
    		'name' => __( 'Primary Widget Area', 'patriot' ),
    		'id' => 'primary-widget-area',
    		'description' => __( 'The primary widget area', 'patriot' ),
    		'before_widget' => '<div class="custom">',
    		'after_widget' => '</div>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>',
    	) );

    which resulted in :

    <div class="custom">
       <h3>widget title</h3>
       some widget content ...
    </div>

    Is there a way to add a wrapping for the widget content?

    TIA

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    I don’t know if this works but give it a try:

    register_sidebar( array(
    		'name' => __( 'Primary Widget Area', 'patriot' ),
    		'id' => 'primary-widget-area',
    		'description' => __( 'The primary widget area', 'patriot' ),
    		'before_widget' => '<div class="custom">',
    		'after_widget' => '</div></div>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3><div class="custom-wrapper">',
    	) );

    Thread Starter duckzland

    (@duckzland)

    Thanks for the reply,

    I tried it and it is working if the widget has title, and if the widget has no title then the html would look like :

    <div class="custom">
        some widget content .....
       </div>
      </div><!-- notice the extra closing div -->

    Thus breaking all the theme layout.

    Moderator keesiemeijer

    (@keesiemeijer)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Theming the sidebar’ is closed to new replies.