I am developing a custom theme and the navigation part uses hashtags (yes, all content is on one page). So when i use

wp_nav_menu( array( 'theme_location' etc

the menu items links to the pages. Can i use/edit wp_nav_menu so it adds a # for every page link, like




Or should i create a custom menu function?

bonus question: Why doesn't wp_get_nav_menu_items give me the permalink/slug for post_name but just the post number as post_name? (see http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items)


2 Answers 2


You already hinted it yourself: When you look at wp_get_nav_menu_items() you'll see that the resulting Array of items gets mapped over with wp_setup_nav_menu_item() - in other words, this function gets applied to each and every nav menu item.

In there you can hook into the 'wp_setup_nav_menu_item'-filter with its $menu_item argument, or use one of the filters in the applied functions in between. The level of control just lays in what you use where (look up source). The argument itself is an object that you can influence.


Probably the easiest way to make menu items with hashtags is to use the Custom Links Box on the Menu Screen.

Custom links allow links defined by you that don't fit into the other types of menu items.

Regarding your second question, get the post_title if you want the name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.