newkind
Member
Posted 2 years ago #
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>) ?
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?
newkind
Member
Posted 2 years ago #
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..