I want remove last after wp_nav_menu

This will replace the last occurrence of your after string. function replace_last_nav_item($items, $args) { return substr_replace($items, ”, strrpos($items, $args->after), strlen($args->after)); } add_filter(‘wp_nav_menu’,’replace_last_nav_item’,100,2); Pure CSS will do this too: .btn_bar:last-child{display:none}

Adding html elements to wp nav menu

I made a dynamic menu using this code: //add login/logout link to menu add_filter(‘wp_nav_menu_items’, ‘wps_add_login_logout_link’, 10, 2); function wps_add_login_logout_link($items, $args) { $login = __(‘Sign in’); $logout = __(‘Sign out’); $menu_id = ’15’; $menu_id2 = ’16’; if ( ! is_user_logged_in() ) $link = ‘<a href=”‘ . site_url(‘log-in-log-out’) . ‘”>’ . $login . ‘</a>’; else $link = … Read more

Minor css-change based on topmenu – how?

My answer adds a class to the <body> element via the body_class filter. This is probably the easiest way to apply extra formatting to any element on the page. The added classes are wpse14430_products, wpse14430_services or wpse14430_contact (based on the slugs of the top pages in your example). Using wp_nav_menu() If you use wp_nav_menu() to … Read more

Is it possible to add a filter for the output of nav-menu items in admin?

These fields are created in Walker_Nav_Menu_Edit::start_el(). To change or to remove them, create a custom walker (example for another walker) that extends Walker_Nav_Menu_Edit and uses other or less fields. Then filter wp_edit_nav_menu_walker and return the class name of your walker. Pseudo-code: class Walker_Nav_Menu_Edit_Simple extends Walker_Nav_Menu_Edit { public function start_el( &$output, $item, $depth = 0, $args … Read more

Custom nav walker with different output depending on depth

Sounds like you want to check the $depth variable. A depth of 0 is a top level item, a depth of 1 is a child of a top level item, etc. So in keeping with your current code, you could factor out that logic this way: $format=”%1$s<a%2$s><div>%3$s%4$s%5$s</div></a>%6$s”; if( $depth > 0 ) $format=”%1$s<a%2$s><div class=”flintstone-nav”>%3$s%4$s%5$s</div></a>%6$s”; $item_output … Read more

Adding a class (arrows) to main menu links that have children?

There are two ways of doing this: Javascript. You could use JQuery to select the <li> that have <ul> children of class ‘sub-menu’, inserting content, or appending a CSS class which you then style. For example: $(‘.sub-menu’).parent().addClass(‘myclass’) PHP, a new walker function. Copy the code from wp-includes/nav-menu-template.php (until approx line 109) into your themes functions.php … Read more

How to implement separate sub-menus?

I can somehow understand what you are asking for but I think you should make this more clear. You already posted an example, but I think the main problem is: You connect some type of data to each other which is not known to wordpress. So as long as you don’t provide some hint how … Read more