Wordpress - Add a div around archive widget
I use Wordpress and have a sidebar containing widgets, run by this code:
<div class="sidebar modern">
<?php if ( is_active_sidebar( 'sidebar-modern' )) : ?>
<ul>
<?php dynamic_sidebar( 'sidebar-modern' ); ?>
</ul>
<?php else : ?>
开发者_如何学C <?php endif; ?>
</div>
What I do in wp-admin
- I add the archive widget
- I set display as a select-list (dropdown) in widget options
What I need is to add a container HTML class to the select.
I have tried these and failed:
- CSS (because it's a design thing)
- Filter - widget_archives_dropdown_args
- Filter - wp_get_archives filter
If it's possible to add a container class to all the widget inside (widget title not included), it would be fine by me.
Where you register the sidebar:
register_sidebar( array(
'name' => 'Sidebar Modern',
'id' => 'sidebar-modern',
'before_widget' => '<div id="%1$s" class="%2$s widget clearfix">',
'after_widget' => '</div>',
'before_title' => '<h3 class="title">',
'after_title' => '</h3>'
) );
Modify it like so:
register_sidebar( array(
'name' => 'Sidebar Modern',
'id' => 'sidebar-modern',
'before_widget' => '<div id="%1$s" class="%2$s widget clearfix">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="title">',
'after_title' => '</h3><div>'
) );
The key is the extra divs:
'after_widget' => '</div></div>'
'after_title' => '</h3><div>'
EDIT:
As Ionut Staicu pointed out, you can just do it like so:
register_sidebar( array(
'name' => 'Sidebar Modern',
'id' => 'sidebar-modern',
'before_widget' => '<div><div id="%1$s" class="%2$s widget clearfix">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="title">',
'after_title' => '</h3>'
) );
It's not possible right now without editing the Wordpress core.
精彩评论