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.
40
votes
10answers
16k 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" ...
32
votes
3answers
29k 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
| ...
18
votes
2answers
13k 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 ...
13
votes
4answers
5k 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
2answers
12k 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' => ...
12
votes
7answers
15k 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 ...
12
votes
2answers
9k 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 ...
12
votes
1answer
949 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 ...
11
votes
7answers
9k 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 ...
11
votes
3answers
5k 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 ...
11
votes
2answers
5k 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.
10
votes
2answers
3k 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 ...
9
votes
8answers
3k 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 ...
9
votes
7answers
6k 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 ...
9
votes
4answers
3k 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 ...
9
votes
2answers
6k 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 = ...
8
votes
3answers
3k 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.
...
8
votes
1answer
3k 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
1answer
425 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 ...
7
votes
1answer
653 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 ...
6
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" ...
6
votes
2answers
551 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 ...
6
votes
2answers
1k 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
1answer
162 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
3answers
8k 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 ...
5
votes
4answers
556 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
2answers
6k 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
5answers
316 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
455 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
1answer
3k 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
2answers
2k 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?
5
votes
2answers
1k 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>
...
5
votes
1answer
326 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
1answer
3k 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 ...
5
votes
2answers
3k 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
656 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 ...
4
votes
4answers
5k 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 ...
4
votes
2answers
4k 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 ...
4
votes
3answers
411 views
How do I add support to my theme for custom menus?
I've read a few tutorials on how to add the functionality of the custom menus added in version 3.0 to my theme but they all seem to differ somewhat, and I'm not sure whether they contain superfluous ...
4
votes
2answers
2k views
Adding a Custom Post Type into the menu screen
I need a way of adding custom post types to the "Appearance-->Menus" option in Wordpress. i have created a custom post type with:
register_post_type('produksjoner',$args);
All examples I find just ...
4
votes
3answers
2k views
non-clickable placeholder in the menu
well, I really would like one & more of my top-level menu items (parent menu items that has child menu items) to be non-clickable, so that visitors can only click on the child menu items...could ...
4
votes
3answers
5k views
wp_nav_menu remove class and id from li
I'm new to wordpress and trying to learn my way through from making a theme.
Right now I am using wp_nav_menu to generate my menu
My menu consists of pages and categories
However, the default ...
4
votes
2answers
1k views
Custom Post Type Menus
I'm writing a plugin for work because our main website is being ported to WordPress eventually. I've got multiple custom post types planned for this plugin and would like to group them all into one ...
4
votes
2answers
75 views
Get page IDs from nav items
I am trying to get all the IDs in my navigation and convert it to a string so that I can use it with wp_query to get the pages that are only listed in the nav. The code to get the IDs:
$menu_name = ...
4
votes
2answers
115 views
Add Commas Between Menu Items?
I created a menu in wordpress in the Menus section of the backend is there any way to display the menu links with commas so it displays as Link1, Link2, Link3, Link4?
4
votes
2answers
977 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 ...
4
votes
1answer
410 views
Attaching a navigation menu to the admin bar?
I have seen a number of solutions of how to manually attach links to the new WP admin bar, but I need to make this much easier for my site admins.
It occurred to me that the easiest solution would be ...
4
votes
2answers
725 views
Any official way to create an admin theme?
I was wondering whether there's a common way of customising the aspect of the admin panel.
I know you can play with the css and js files but what I was looking for is some kind of "admin theme" like ...
4
votes
1answer
446 views
Highlight parent menu item when child is not in menu
I want to highlight the parent of a child page in the menu when the child page itself is not in the menu.
I know this would work if you add the child as a sub page but that isn't the case.
Any ...
4
votes
2answers
104 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 ...
