how to add a class to a child unordered list?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saturnstroll
Forum Newbie
Posts: 8
Joined: Fri Aug 03, 2007 4:46 pm

how to add a class to a child unordered list?

Post by saturnstroll »

I've successfully added a few classes to the first ul in wordpress' template tag: wp_page_menu,
however, I haven't been able to add a class to the child ul nested in the first li.
Anyone see what is missing?

Code: Select all

function add_menuclass($ulclass) {
return preg_replace('/<ul>/', '<ul class="clearfix rMenu-hor rMenu">', $ulclass, 1);
}
function add_sub_menuclass($ulchildclass) {
return preg_replace('/<ul>/', '<ul class="rMenu-expand">', $ulchildclass, 2);
}
add_filter('wp_page_menu','add_menuclass','add_sub_menuclass');
 
I entered "2" at the end, see:

Code: Select all

$ulchildclass, 2);
I tried adding a div as 'TheFrosty' suggested in the comments on this tutorial http://themeshaper.com/adding-class-wor ... page-menu/, but no go.

Thoughts?
saturnstroll
Forum Newbie
Posts: 8
Joined: Fri Aug 03, 2007 4:46 pm

Re: how to add a class to a child unordered list?

Post by saturnstroll »

Post Reply