Add custom text to menu

There is another alt way to do this with CSS3. You would add a link to the WP Menu as normal but make the Location either javascript:void(0); or # so it doesn’t go anywhere (I would say the javascript… is the better way to prevent anchor link from firing). Then in your style.css or CSS … Read more

Subpages in Menu Editor not Nesting

For those who run into this in the future, the issue was due to pagination and the parent appearing on a different page than the children. Removing pagination from the View All menu fixed the nesting. There is a ticket opened 7 years ago reporting this bug and it has yet to be resolved. In … Read more

Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?

The problem is that do_shortcode() expects a string in it’s first parameters while wp_nav_menu_objects get’s passed an array of menu objects. Sou you’d have to write your own wrapper function to do_shortcode, something like this… function my_nav_menu_objects_shortcode_mangler($items) { foreach ($items as $item) { $item->classes = explode(‘ ‘, do_shortcode(implode(‘ ‘, (array)$item->classes))); } return $items; } may … Read more

Keep parent page active

The parent page li receives the css classes current_page_parent and current_page_ancestor, style them to be similar to, or add them to the rules for current_page_item or current-menu-item in your theme’s style.css.

Add tabindex to navmenu

You could write a custom walker to change the output of wp_nav_menu(). The walker should extend the function start_el() to add your attributes where you need them. Another option would be a filter on ‘walker_nav_menu_start_el’. But be aware that tabindex can make a page less accessible. If don’t have an urgent problem to solve do … Read more

wp_nav_menu() mark current item ancestor of custom post type

I do the following, it can be lengthy if you have many post types, feel free to edit it however: /** Edit Nav Menu calsses **/ function custom_wp_nav_classes($classes, $item){ global $post; $page_blog = get_option(‘page_for_posts’); if(is_tax(‘my_taxonomy_name_here’) || is_singular(‘my_post_type_name_here’)){ /** Remove Active Class from Blog **/ if($item->object_id == $page_blog) $classes = array_filter($classes, “remove_parent”); /** Page ID of … Read more

Hide Menu items base on capability

Create a custom walker. Redefine the method start_el() only: function start_el( &$output, $item, $depth, $args ) { if ( ‘Your secret item title’ !== $item->title or current_user_can( ‘administrator’ ) ) { parent::start_el( &$output, $item, $depth, $args ); } } Please mind that this is just pseudo code. I can not give it a test at … Read more