Hot answers tagged

5

I was curious and decided to check it out, regardless if it's relevant for a CSS problem ;-) I first peeked into the database tables to find more about the menu structure: Menu - building blocks Each navigational menu is registered as a term in the nav_menu taxonomy. Then when we add items to that menu, we are creating new post objects of the type ...


2

This should add the drop class to all the li elements in the menu and also add your classes to the wrapping ul: function wpse_232637_add_menu_parent_class( $items ) { foreach ( $items as $item ) { $item->classes[] = 'drop'; } return $items; } add_filter( 'wp_nav_menu_objects', 'wp_232637_add_menu_parent_class' ); $args = ...


2

These are almost certainly custom post types. In the definition of the custom post type, it is possible to define a menu_icon which can be a file or an icon from the iconfont. It is this menu_icon that is showing up in your admin menu. I also notice "Programs Categories" in your menu, this looks like a custom options page - which will have also been ...


1

It's called "event bubbling" or "event propagation" and the solution is to get the event object and use the JS stopPropagation method. Try this: jQuery('.menu-item').click(function(event){ var class_id = jQuery(this).attr('id'); event.stopPropagation(); alert(class_id); });


1

https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/ function my_nav_menu_primary_navigation($items, $args) { $items .= '<li>Hello :D</li>'; return $items; } add_filter( "wp_nav_menu_{MENU SLUG}_items", "my_nav_menu_primary_navigation", 10, 2 ); find {MENU SLUG} EDIT: The "wp_nav_menu_menu-slug_item" filter ...


1

Thanks for the help birgire. That gave me a lot to think about. Eventually I have came up with a solution using a filter I can count the number of parents the menu has. The only problem with this approach is that it will run every time a menu is displayed. function my_nav_menu_objects($sorted_menu_items, $args) { if($args->menu == 'header_menu') { ...


1

one problem exists there... Wordpress has built-in page detection, to give the CSS classes to current page in menu... and if cached, then your navigation menu-items will never get "current-page" class or etc.. however, there are 2 solutions: Solution 1 Before caching, once, add classes to <a> items: function add_menu_atts( $atts, $item, $args ) { ...



Only top voted, non community-wiki answers of a minimum length are eligible