Quantcast
Viewing all articles
Browse latest Browse all 8245

Bmathers on "Custom Class on anchors in menu li items"

Hi,

I have the following code

<?php
function menu_element_class($classes, $item){
    if($item->ID == 21 || $item->menu_item_parent == 21) {
        $classes[] = "menu_element";
    }
    return $classes;
}

add_filter('nav_menu_css_class' , 'menu_element_class' , 10 , 2);
?>

I found this running through some previous questions around this area. However this adds the class to the list item and not the "element" beneath it.

The real reason i want it is i would like to have some of my main navigation items pop up in a thickbox, i have the thickbox plug in and it works, i just need the class="thickbox" assigned to it.


Viewing all articles
Browse latest Browse all 8245

Trending Articles