• rgregory

    (@rgregory)


    Ok, in 2.7 I would like to learn how to add a single class to an element in the menu.

    I have found a tutorial how to add class to the entire menu here, https://themeshaper.com/adding-class-wordpress-page-menu/

    // Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
    function add_menuclass($ulclass) {
    return preg_replace('/<ul>/', '<ul id="nav" class="something-classy">', $ulclass, 1);
    }
    add_filter('wp_page_menu','add_menuclass');

    I think you could change it to add a class to say the ‘contact’ page, but cant’ figure out the selectors. Can anyone help?

  • The topic ‘Add class to single link in wp_page_menu’ is closed to new replies.