Add Commas Between Menu Items?

Use a very simple custom walker … class WPSE_82726_Comma_Walker extends Walker { public function walk( $elements, $max_depth ) { $list = array (); foreach ( $elements as $item ) $list[] = “<a href=”https://wordpress.stackexchange.com/questions/82726/$item->url”>$item->title</a>”; return join( ‘, ‘, $list ); } } … and call your menu like this: wp_nav_menu( array ( ‘theme_location’ => ‘your_registered_theme_location’, ‘walker’ … Read more

Check if a menu is empty?

wp_nav_menu has the argument fallback_cb, which is the function called if a menu doesn’t exist. This is set to wp_page_menu by default, which is why you see a list of pages if the menu doesn’t exist. If you explicitly set that to false, then nothing will be output if the menu doesn’t exist. EDIT- Given … Read more

How to target specific wp_nav_menu in function?

I tried the below code and it worked. Add this to your functions.php register_nav_menus(array( ‘top-menu’ => __(‘Menu1’, ‘twentyfourteen’), ‘side-menu’ => __(‘Menu2’, ‘twentyfourteen’), ‘footer-menu’ => __(‘Menu3’, ‘twentyfourteen’) ) ); function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) { $menu_locations = get_nav_menu_locations(); if ( has_term($menu_locations[‘top-menu’], ‘nav_menu’, $item) ) { $item_output = preg_replace(‘/<a /’, ‘<a class=”list-group” ‘, $item_output, 1); } return … Read more

Custom Post Type Menus

You got it right but you need to wait for WordPress 3.1 where its actually implemented. if you can’t wait you can change ‘show_in_menu’ to false and use add_submenu_page() function define ‘argus’ as top page and add the Visitors “manually” under Argus Admin menu. so your code would be: $v_args = array( ‘labels’ => array … Read more

How to use a WordPress’ existing admin icon?

add_menu_page(); as far as I can tell does not work with screen_icon or the default CSS parameters. The $icon paramater only takes 2 options, an url or div (well 3 if you leave it empty), so that leaves you with these options: Hard-code the link to the icons which are located in wp-includes/images/wpicons.png. This is … Read more

wp_get_nav_menu_items how to exclude sub level menu items?

Think I worked it out!! I did a print_r on each $menu_item and saw there’s an array key called menu_item_parent in there. So I changed this: foreach ( (array) $menu_items as $key => $menu_item ) { $title = $menu_item->title; $url = $menu_item->url; $menu_output .= ‘<option value=”‘ . $url . ‘”>’ . $prefix . $title . … Read more

How do I create predefined menus for my theme?

Example code taken from new2wp.com located HERE // Function for registering wp_nav_menu() in 3 locations add_action( ‘init’, ‘register_navmenus’ ); function register_navmenus() { register_nav_menus( array( ‘Top’ => __( ‘Top Navigation’ ), ‘Header’ => __( ‘Header Navigation’ ), ‘Footer’ => __( ‘Footer Navigation’ ), ) ); // Check if Top menu exists and make it if not … Read more

non-clickable placeholder in the menu

Yes, this is possible by adding a custom link to the menu assigning it any url (for this example I just added #) then click add to menu. Once it’s on the menu open it and remove the url you assigned and save. If you don’t put the url initially WordPress won’t let you add … Read more