Navigation Menu is a theme feature introduced with Version 3.0. WordPress includes an easy to use mechanism for introducing customised navigation menus into a theme. In order to incorporate menu support into your theme, you need to add a few code segments to your theme files.

learn more… | top users | synonyms (4)

49
votes
11answers
22k views

Display a portion/ branch of the menu tree using wp_nav_menu()

I have a menu defined in WP Admin that looks like this: I want to be able to display all the child links on the sidebar whenever I am at a parent page. For example, if the user is on my "About Us" ...
43
votes
3answers
43k views

Menu items description? Custom Walker for wp_nav_menu()

Normal Wordpress Menu looks like: Home | Blog | About us | Contact But I've seen many pages with descriptions under these links: Home Page | Our Blogs | About us | ...
20
votes
2answers
17k views

Any docs for wp_nav_menu's “items_wrap” argument?

I'm using wp_nav_menu and am trying to create custom output for the sub-level drop downs. I came across the "items_wrap" argument but there's really not much information as to what it is, how it ...
19
votes
2answers
14k views

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

Thanks to some help on here, I've managed to add a custom search box to my main menu... by adding this to my theme's functions.php add_filter('wp_nav_menu_items','search_box_function'); function ...
16
votes
7answers
20k views

Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?

(Moderators note: Was originally titled "wp_nav_menu Ancestor class without children in navigation structure") I have a wp_nav_menu in my header which had three pages in it. When I am on one of those ...
16
votes
3answers
7k views

Programmatically add a Navigation menu and menu items

Through API functions, I want to define a new Navigation menu, select it in the current theme, and then insert a few Pages as menu items. This is to be done for instance on a theme activation. ...
16
votes
2answers
8k views

How to add a custom field in the advanced menu properties?

Is it possible to add a custom field to menu items? What I want to do is be able to add a field for 'French Navigation Label' and a 'French Title Attribute' in the wp menu interface.
15
votes
2answers
4k views

add_menu_page() with different name for first submenu item

The add_menu_page documentation says to pass the menu title as the second parameter: add_menu_page('Page Title', 'Menu Title', ...); When adding more pages later via add_submenu_page, the main page ...
15
votes
2answers
18k views

How to use wp_nav_menu to create a select menu dropdown?

I'm using the following inside the wp_nav_menu function to create a select dropdown menu where each menu item is an option in the select dropdown... 'items_wrap' => ...
14
votes
6answers
12k views

Changing the Order of Admin Menu Sections?

I am getting a bit frustrated over here after having spent a few hours trying to accomplish this fairly simple task without any luck. Essentially I have 5 custom post types which I created and all I ...
14
votes
2answers
4k views

Adding an Arbitrary Link to the Admin Menu?

Is there a way to add a arbitrary hyperlink to the WordPress admin menu (I mean the menu on the left when you log into the admin dashboard)? For example, can one add a link to Google? In my ...
14
votes
4answers
8k views

Add 'has_children' class to parent li when modifying Walker_Nav_Menu

I'm writing a customised walker class for wp_nav_menu and want to be able to specify if an li contains a submenu. So I want my markup to be: <li class="has_children [other-wordpress-classes]"> ...
13
votes
4answers
8k views

How to Hard Code Custom menu items

Is there any way that i can hard code the custom menu items when first theme installed? I am creating a theme which will automatically make some common pages when installed. So I need to know if I can ...
10
votes
9answers
4k views

Adding first / last CSS classes to menus

is that possible, without javascript hacks? like this: <ul class="my_menu"> <li class="first"> ... </li> <li> ... </li> <li> ... </li> <li ...
10
votes
8answers
8k views

Adding custom post type archives to a WordPress menu

Is there a way (besides adding a Custom Link) to add a custom post type archive to a menu in WordPress? If it's added using a custom link (e.g. /cpt-archive-slug/), WordPress does not apply classes ...
10
votes
4answers
4k views

Adding an Archive of Posts to the Navigation Menu in WordPress 3.0

Hay all, I'm playing around with WordPress 3.0 and two (2) of the new features, Custom Post Types and the Menu Editor. I've started off by creating a new post type called "products", as you've ...
10
votes
2answers
8k views

Generate a Menu that Displays Child Pages using wp_list_pages() with the New Menu Functionality in WordPress 3.0?

Previously, I was able to selectively load child pages for a currently-selected parent page using logic such as: if( $post->post_parent ) { $children = ...
10
votes
3answers
2k views

Custom Nav walker display current menu item children, or siblings on no children

I've been messing around / searching for hours and still can't get this to work, so i'm finally giving in and asking for some help. I'm trying to write a custom walker that shows only the current ...
8
votes
1answer
4k views

add custom class to wp_nav_menu using filter hook nav_menu_css_class

I have a custom post type in my wordpress theme. I want to add a custom class to the nav menu for the pages created in that custom post type. I read that you can use a filter hook: ...
7
votes
2answers
15k views

How make top level menu item not have link, but have sub-menus that are linked?

I'm building a horizontal menu and some of the entries on that menu will have dropdowns (sub-menus), and some won't. Those that have sub-menus are not actually pages. They're just meant to be guides ...
7
votes
2answers
917 views

Add Caret to Menu Items with Sub-Menus in WordPress Theme

I'm working on a custom theme using wp_nav_menu(). What I want to do is add a caret to menu items that have sub-menus. For example, If my menu looks like this: Menu Item 1 Menu Item 2 Menu Item ...
7
votes
3answers
3k views

remove “edit your profile” from admin menu bar

How can I remove "edit your profile" submenu under "my-account-with-avatar" admin menu bar, while still keeping the avatar and logout?
7
votes
2answers
3k views

Display Menu Name using wp_nav_menu

I have a custom menu that I can call just fine using wp_nav_menu. Is there a way to have the menu name displayed inside an h3 tag before the menu? Ex. <h3>My Menu Name</h3> <nav> ...
7
votes
1answer
4k views

How to add custom post type archive page links to nav menu?

I cannot figure this out. There seems to be no checkbox or anything similar in function to add the newly created custom post type archive page into the menu. Also the link must be active, if you are ...
7
votes
1answer
535 views

Assign a Class to the Current “Tag” for Formatting

Essentially what I am hoping to replicate is something like the "current-menu-item" class that is applied to WP Menus. My client is wanting to use Tags as a sub-nav, and I've managed to get the tags ...
6
votes
3answers
10k views

Remove wrapping div and ul from output of wp_nav_menu

I am using the new menu system of Wordpress, and here is the result of wp_nav_menu() <div class="menu-main-menu-container"> <ul id="menu-main-menu" class="menu"> <li ...
6
votes
2answers
5k views

How to manually specify the current active page with wp_nav_menu()

Is there a way of manually specifying which page is currently "active" when using wp_nav_menu()? I have a "Products" page, and on that page I have links to various (dynamic) custom taxonomies. When I ...
6
votes
1answer
115 views

Check if add_menu_page exists or not

I'm working on a plugin that I have to release in parts. The problem is, if there is a menu in the page then add the new plugin to the 2nd or next submenu else add a new menu and then add the plugin ...
6
votes
2answers
2k views

How to add a custom metabox to the Menu Management admin screen?

Although I am very thankful to the wordpress core team that they have finally integrated native menu management capabilities I get frustrated with some key elements which I would like to change. I ...
6
votes
2answers
61 views

Filter wp_nav_menu()

I try to split my navigation into 3 single navigation bars (level 1, level 2 and level3+). Three because they're separated over the site and they should only appear depending on the current page. ...
6
votes
1answer
208 views

New post notification in wp_nav_menu

By blog has a header menu that consists of different links to pages like "About Us", "Help", "Contact Us" and "Blog". The "Blog" link is actually a page with a custom template that displays all the ...
5
votes
6answers
1k views

Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?

Below is an example. 3 classes attached to each item, except current item, which has 6. Can I pare this down somehow? <ul id="menu-global-nav" class="sf-menu"> <li id="menu-item-63" ...
5
votes
1answer
10k views

How to add posts to custom menus?

I'm just beginning to work the "Custom Menu" functionality that was introduced in 3.0 into my theme. I like everything about this new capability and API, with one exception: Why no posts? I can ...
5
votes
4answers
7k views

Add Class to Specific Link in Custom Menu

I know you can add a class in the custom menu options, but it adds it to the LI before the A. I want to apply the class directly to this specific A rather then the whole LI. So instead of the output ...
5
votes
4answers
616 views

How can I enable Google Analytics on a file download link?

I'm using Wordpress to present some software for download. The download links are provided via Custom Link entries in a side menu. I would like to enable Google Analytics tracking for these file ...
5
votes
3answers
10k views

wp_nav_menu(), how to change <li> class?

I'm building a menu for my website. The static is looking like this: <nav> <ul id="menu"> <li class="item_1"><a href="#">Item 1</a></li> <li ...
5
votes
2answers
2k views

WordPress Menu Custom Walker Class

We are using a jQuery UI accordian to render a menu in the sidebar. We've already written the markup and javascript and I am just trying to get the wp_nav_menu to output the same markup we've already ...
5
votes
5answers
1k views

Add separator to admin submenu

I would like to add a separator to the admin submenu section, NOT in the top level section. I'm thinking of using javascript and styling to do the job, but I was wondering if there's a more ...
5
votes
1answer
681 views

Deleted pages are NOT removed from custom menus?

When I delete a page, post or category that has previously been added to a custom menu, the delete routine is apparently not checking to see if the item belongs to a custom menu, and thus its not ...
5
votes
2answers
1k views

How can I create an auto-populated menu that is automatically assigned to a location?

I'm trying to add BuddyPress nav menu support to my theme and, unfortunately, BP's template tags still aren't fully up to snuff. (Basically, if you're not making an explicit child theme for the BP ...
5
votes
2answers
2k views

fall back for main menu?

I am new to WordPress, and am still trying to learn the in's and out's in much respect to this well known CMS. I am wanting to know, if I should or must have a Fallback for main menu? This is what I ...
5
votes
1answer
6k views

Display only page specific sub menu items using Custom Walker

I've just implemented the technique described at http://wordpress.org/support/topic/wp_nav_menu-list-only-2nd-level-separate-submenu/page/2 when implementing a theme for a client. When I run the theme ...
5
votes
1answer
1k views

Custom ID for certain menu item?

I'm displaying Wordpress menu using this function: wp_nav_menu( $args ); Menu is set in wp-admin/nav-menus.php. Can I somehow attach ID of my choice to one of the items? I want the menu to look ...
5
votes
2answers
301 views

Call custom field into menu item

I have a navigation menu in Wordpress. I would like it to check if the page has a custom field of "menu_icon" and if it does, add that custom field into the menu item it corresponds to. I'm sure this ...
5
votes
1answer
1k views

How to avoid wp_nav_menu() ID conflict?

How do I avoid ID conflicts if I use the same menu TWICE on one page. FIRST wp_nav_menu( array( 'sort_column' => 'menu_order', 'theme_location'=>'menu', 'menu_class'=>'menu', ...
5
votes
3answers
1k views

Making breadcrumb with wp_nav_menu

I was looking for a quick and dirty method to output a breadcrumb navigation on a WP site, without requiring the installation of a plugin and also leveraging the built-in WP menu. Here's what I came ...
5
votes
1answer
401 views

How do I add nested categories to drop-down menu in twenty-eleven?

I know how to do it by writing a separate ul/li css for wp_list_categories, but I find menus of "twenty eleven" already well designed and flexible, so I`d like to use them. Custom menus, when I have ...
5
votes
3answers
5k views

How to add a Custom Link to a Menu with an URL that is relative to the blog URL

Part of my work is to create Wordpress websites. I usually work on my laptop until I have something good enough to be uploaded to the test server where the client reviews it. I create a VirtualHost ...
5
votes
3answers
700 views

Can I display submenus in groups, using wp_list_pages?

Say I have top-level(parentless) pages called Fruit, Animals, Cars. When, say, Fruit is selected I would like to show links to the individual fruit pages below. I would like to be able to dislpay ...
5
votes
1answer
1k views

How to add sub-menu to a menu generated by wp_nav_menu by using plugin

I have a menu generated by wp_nav_menu which look like <ul class="nav-menu" id="menu-top-nav"> <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-43" ...