WordPress add class to parent element if has submenu (3 posts)

  1. iversoncreative
    Posted 3 years ago #

    I need to be able to add classes to a parent <li> as well as the child <ul> element in WordPress like so:

        <li>Top Level Page</li>
        <li class="NEED-NEW-CLASS-HERE">Top Level Page with Children
            <ul class="AND-HERE">
                <li>Child Page</li>

    I can't quite seem to grasp the whole walker thing, and do not want to do it via jquery. This seems common enough, but I can't find a working answer anywhere. Has anyone here seen or done this? Any help and insight would be greatly appreciated.

  2. thisislawatts
    Posted 3 years ago #

    As this page was pretty quickly returned in my Google search, fellow knowledge seekers can find a solution over on StackOverflow --> http://stackoverflow.com/questions/8448978/wordpress-how-do-i-know-if-a-menu-item-has-children

  3. mread1208
    Posted 3 years ago #

    That worked like a charm, thanks for the post.

Topic Closed

This topic has been closed to new replies.

About this Topic