Filter menu item to add classes/attributes?
Filter menu item to add classes/attributes?
Filter menu item to add classes/attributes?
I think the plugin you mention is the one I wrote so if you’re looking for answer on how to do it take a look at the code. http://wordpress.org/extend/plugins/dropdown-menus/ Essentially all I did was create a custom menu walker class so I could output the menus created in the backend as a dropdown. If it … Read more
Terms with more than one occurrence have current-menu-item class in menu
In your example, the ‘Key Industries’ page appears to be a different page under each of those top level menus – or at the very least, the URL is different. This most likely allows their CMS to differentiate and use the correct submenu. Here’s what I do when I want to achieve this: Hook into … Read more
You should change this line: echo “post_parent).”\”>”.get_the_title($post->post_parent) . “”; To something like this: echo ‘<a href=”‘. get_permalink($post->post_parent).'”>’. apply_filters(‘the_title’, get_the_title($post->post_parent)) .'</a>’;
I don’t like the idea to parse the menu items again. As an alternative solution I suggest to store the description during the first run: add_filter( ‘walker_nav_menu_start_el’, ‘wpse_78483_get_current_items_description’, 10, 2 ); /** * Get nav items description. * * @wp-hook walker_nav_menu_start_el * @param string $item_output * @param object $item * @return string */ function wpse_78483_get_current_items_description( … Read more
This can be done via cookies. We set it with Javascript, reload the page and display different menus in PHP using its value. First, print the script at the site footer (see comments). Note: would be better to enqueue this together with your theme scripts. add_action( ‘wp_footer’, ‘wpse_77220_language_cookie’ ); /** * Cookie script based on … Read more
There is a nav_menu_css_class filter. It is trivial to add classes. function add_classes_wpse_130358($classes, $item, $args) { $classes[] = ‘new-class’; return $classes; } add_filter(‘nav_menu_css_class’,’add_classes_wpse_130358′,1,3); But you will probably need to extend Walker_Nav_Menu or use the walker_nav_menu_start_el filter instead, since the nav_menu_css_class filter mysteriously does not have access to the depth variable. But walker_nav_menu_start_el doesn’t let you … Read more
Ok, here we go. I extended the default Navigation widget for you. Add this to your themes functions file. After you have done this, go to widgets in your dashboard and you will see a widget called ‘Matt Royal Custom Menu’ now. Use this one. In the below code, the div class has been added … Read more
(Untested). But if you want to use HTML in the description, then you shouldn’t use: `esc_html( $item->description )` Try removing the esc_html as this escapes the HTML. (Or better still use wp_kses instead to only allow certain tags.). So you want $description = ( ! empty ( $item->post_content ) and 1 == $depth ) ? … Read more