• Resolved newkind

    (@newkind)


    Hi,

    If i got menu generated by wp_list_pages ie.

    <ul class="something">
        <li>
           <a href="wordpress.com/link">Text</a>
               <ul>
                    <li><a href="wordpress.com/link2">Submenu Link</a></li>
               </ul>
        </li>
    </ul>

    how can I add a class to
    <li> and <a> only where is the submenu (nested
    <ul>) ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You want to add a class to the <li> and <a> elements that are produced in the output of wp_list_pages? Is that right?

    Thread Starter newkind

    (@newkind)

    yes, but only for those <li> and <a> which has another <ul> (for subpages) nested – so only those <li> and <a> that are parents

    wp_list_pages already assigns classes..

    If you want to style them differently just use the classes..
    Top level..
    ul li.page-item {}
    child level lists..

    ul li.page-item ul {}
    ul li.page-item ul li.page-item {}

    child child..

    ul li.page-item ul li.page-item ul {}
    ul li.page-item ul li.page-item ul li.page-item {}

    and so on…

    You’ll need some heavy regex to do it otherwise.. I’m not quite that hot with regex, else i’d write you something..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_list_pages and class to <li> and <a>’ is closed to new replies.