Add class to <ul> on sidebar widget

by user8463989   Last Updated July 12, 2019 08:08 AM - source

I have been looking on stack overflow and the web but can't find a simple solution for this.

I just want to add a class to the of the widget sidebar generated by Wordpress.

This is my register sidebar code:

    register_sidebar( array(
    'name' => __(' Main Sidebar ', 'mystic'),
    'id' => 'sidebar-2',
    'class' => 'submenu',
    'description' => __( 'Main Sidebar', 'mystic' ),
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h6>',
    'after_title' => '</h6>'
));

The html output of the actual unordered list is:

<ul>
    <li>
        <a href="http://localhost:8888/a-third-post/">A Third Post</a>
    </li>
    <li>
        <a href="http://localhost:8888/another-post/">Another Post</a>
    </li>
    <li>
        <a href="http://localhost:8888/news-article-title/">News Article Title</a>
    </li>
</ul>

But I want the ul to have a class of 'submenu'

So,

<ul class="submenu">
 <li>
  .....

Surely there has to be an easy way to do this?(without jQuery)



Related Questions



Can't see widget areas in my customizer

Updated February 23, 2018 15:08 PM

How to create sidebar from "scratch"?

Updated December 01, 2017 16:08 PM

More flexible sidebar and widget management

Updated May 01, 2019 20:08 PM

Add divclass to only one widget

Updated February 28, 2017 14:08 PM