How do I remove UL on wp_nav_menu?

The function wp_nav_menu takes an argument of fallback_cb which is the name of the function to run if the menu doesn’t exist. so change you code to something like this: function wp_nav_menu_no_ul() { $options = array( ‘echo’ => false, ‘container’ => false, ‘theme_location’ => ‘primary’, ‘fallback_cb’=> ‘fall_back_menu’ ); $menu = wp_nav_menu($options); echo preg_replace(array( ‘#^<ul[^>]*>#’, ‘#</ul>$#’ … Read more

How to Hard Code Custom menu items

The Problem with your code is that its not actually adding the links to the menu and only to the menu’s output, hence the use of a filter (add_filter) so you are just filtering the output of the menu in fact even if you don’t have a menu your link will be shown with the … Read more

Changing the Order of Admin Menu Sections?

Hi @BinaryBit: It’s no wonder you are a bit frustrated; the admin menu is one of the most obtuse and frustrating implementations through WordPress core. Honestly, I don’t know what they were thinking when they designed it that way. @EAMann did an excellent job of explaining how the admin menus work in WordPress (I wish … Read more

Customizing Only a Specific Menu using the “wp_nav_menu_items” Hook?

To only add the custom search box to the main menu you could pass the second parameter provided by the wp_nav_menu_items filter and check if the theme_location is the primary location add_filter(‘wp_nav_menu_items’,’search_box_function’, 10, 2); function search_box_function( $nav, $args ) { if( $args->theme_location == ‘primary’ ) return $nav.”<li class=”menu-header-search”><form action=’http://example.com/’ id=’searchform’ method=’get’><input type=”text” name=”s” id=’s’ placeholder=”Search”></form></li>”; … Read more

Any docs for wp_nav_menu’s “items_wrap” argument?

The parameter ‘items_wrap’ for wp_nav_menu() defaults to: ‘<ul id=”%1$s” class=”%2$s”>%3$s</ul>’ This a a template that is parsed with sprintf(): $nav_menu .= sprintf( $args->items_wrap , esc_attr( $wrap_id ) // %1$s , esc_attr( $wrap_class ) // %2$s , $items // %3$s ); The numbered placeholders – %1$s, %2$s, %3$s – refer to the arguments after the first … Read more

Programmatically add a Navigation menu and menu items

I might be misunderstanding you, but why not use wp_create_nav_menu()? E.g., this is what I do to create a custom BuddyPress menu when I detect BP as active: $menuname = $lblg_themename . ‘ BuddyPress Menu’; $bpmenulocation = ‘lblgbpmenu’; // Does the menu exist already? $menu_exists = wp_get_nav_menu_object( $menuname ); // If it doesn’t exist, let’s … Read more