Set menu item class into body

You’re going about this backwards. What you want to do is use jQuery to test for the presence of the current menu class, then see if that item has the assigned class. If it does, then you add your CSS to the body. <script type=”text/javascript”> jQuery(document).ready(function($) { if($(‘li.current-menu-item’).hasClass(‘your_custom_class’)) { $(‘body’).css(‘background-color’, ‘orange’); } }); </script> Integrating … Read more

Adding two submenus to a menu

Hope you’ll find this well , I’m adding the code below. This is one of the way of doing it, you can do things in other ways also. add_action(‘admin_menu’,’create_admin_menu’); function create_admin_menu() { add_menu_page ( ‘Page Title’, ‘Top level menu Title’, ‘manage_options’, ‘your_unique_slug’, ‘your_magic_function’ ); function your_magic_function() { include_once(‘first.php’); } add_submenu_page ( ‘your_unique_slug’, ”, ”, ‘manage_options’, … Read more

wp_nav_menu in 3.7 add name class nav navbar-nav

Edit In this case, it appears that the problem is that you’re not actually outputting a custom nav menu at all, but rather the menu fallback: wp_page_menu(). Notice that the classes for the list items are page-item rather than menu-item. That’s a sure giveaway that the output is being generated by wp_page_menu() rather than wp_nav_menu(). … Read more

Add item ONLY to the primairy navigation

i did find my answer here : http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/ add_filter( ‘wp_nav_menu_items’, ‘your_custom_menu_item’, 10, 2 ); function your_custom_menu_item ( $items, $args ) { if (is_single() && $args->theme_location == ‘primary’) { $items .= ‘<li>Show whatever</li>’; } return $items; }

Where these arguments are defined?

You should look on ow WordPress Plugin Api works. When you add a filter, the function that hook into that filter receive the argument from the function: apply_filters. This function pass at least one argument, but can pass more, and always aspect a value returned. So if you can write add_filter( ‘walker_nav_menu_start_el’, ‘description_in_nav_el’, 10, 4 … Read more