I want to assign a new CSS class to default widget <ul>
in Page/Post creating page in WordPress. How can I do this?
See the image below.
I want to assign a new CSS class to default widget <ul>
in Page/Post creating page in WordPress. How can I do this?
See the image below.
Don’t edit your parent theme’s functions.php
file.
register_sidebar( array(
'name' => __( 'Sidebar name', 'theme_text_domain' ),
'id' => 'unique-sidebar-id',
'description' => '',
'class' => 'add class here',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
) );
Copy it over to your child theme’s functions.php
and make the changes there, or simply register a new widget.
You could then hook it in from your child theme’s functions.php
like this:
add_action( 'your_hook', 'new_widget' );
function new_widget() {
if ( is_your_conditional_tag() && is_active_sidebar( 'new-widget' ) ) {
dynamic_sidebar( 'new-widget', array(
'before' => '<div class="new-widget">',
'after' => '</div>'
) );
}
}
You can also add more classes to the dynamic_sidebar function.