wp_nav_menu()
doesn’t return anything by default, it just echoes out formatted html.
For wp_nav_menu()
to return a value you will need to pass 'echo' => false
into it’s arguments, like so:
$housemenu = wp_nav_menu( array(
'menu' => '',
'menu_class' => 'sf-menu',
'menu_id' => 'nav',
'walker' => new description_walker(),
'echo' => 'false'
));
It should be noted that by caching the entire menu in a transient, you will lose it dynamic nature. For instance if it cached it while on your home page all of the active classes applied to the menu items will ALWAYS reflect the home page. Thus if you were to visit a different page the active classes on the menu items would be wrong.
This will cause quite a bit of pain if you wish to convey via CSS which page the current user is on.
Related Posts:
- Should the caching of WordPress menus be specific to each page?
- Nav and logo loading each time causing menu to move JointsWP – Foundation 6
- Custom Nav walker display current menu item children, or siblings on no children
- Does WP REST API have a built in route for calling menu?
- Assign Menus to Theme Locations with theme activation
- wp_nav_menu() doesn’t apply correctly classes and IDs to menu and container
- How to set limit only on top levels of wp_nav_menu?
- Using Image Links in WordPress Navigation Menus Instead Of Text Links
- When add wordpress page in menu it converted in to custom link
- Add items to a menu dynamically
- Disguise Multi-Page site as Single Page
- Add div to specific sub-menu
- How do I create a magazine type menu – sub-menu setup using wp_nav_menu and child of twentyten? [closed]
- Arrow down in menu not displaying
- add span to wp_nav_menu widget
- How to get wordpress nav menu outside of wordpress system?
- Second nav is merged with the first in mobile
- Replace menu permalink/hyperlink with only menu name/slug
- wp_nav_menu add some element to container
- Variables within wp_nav_menu
- wp_update_nav_menu_item not saving in multisite API
- get_search_form() doesn’t appear to take parameter into account
- Custom menu deletes itself
- Header style different on home and remaining pages
- Pass GET params to URL from a main menu item
- show different admin menu to different user roles
- Schedule Page to Menu [duplicate]
- Limit the menu child levels under “admin > appearance > menus”
- display menus on all page except one?
- Show Menu from one WordPress install in another WordPress install
- Check if Page Already Exists in Menu
- Reuse a custom WordPress menu on another WordPress website
- Is this format possible with a custom Nav Walker class?
- Default WordPress menu content
- Add code to WordPress menu items by class
- how do i change the text under a navigation menu [closed]
- How do you add a around the second level of a Menu?
- custom walker nav issue involving ajax
- Remove admin menu
- How to add html attributes to the “ul” html tag with “wp_nav_menu” function?
- Limit User Iinterface for Admin?
- Creating menu and breadcrumb “sections” within WordPress 3 being used as a CMS
- Give child-categories same class (the parent category-slug) as parent in menu list?
- How Do I Add Images To Main Navigation Menu
- Custom Menu not functioning properly
- Is it still not possible to show separate submenu with “Custom Menu”?
- Three menus – parent / child / sibling
- WordPress Nav Walker – Top menu link with dropdown link not clickable (dropdown opens)
- Rename the label on a menu location which is already defined?
- How to making dynamic URLs for menus in WordPress?
- swap out only main menu for logged in users
- Menu Not Showing on Mobile
- Add custom class to li element which has children
- How to Show Different Menus to Logged in Users in WordPress [duplicate]
- Unable to get menu pattern using a walker
- Menu not adding the right items
- Output Post ID for all nav_items
- How to change the menu like this?
- Custom ul class
- wp_nav_menu inside an object — how do I deal with fallback_cb?
- Removing Submenu from Menu
- Walker_Nav_Menu creating too many closing tags?
- Adding conditional classes to wp_get_nav_menu_items
- Theme Menu vs Native Menu
- Custom link missing as option in my ‘add menu items’
- Mobile navigation javascript problem
- Custom menu including also primary menu items
- open menu link (PDF) in new tab not download
- twentysixteen child theme – responsive menu – ham icon button not working – Cannot read property ‘classList’ of null
- How to add Loginout to Sub-menu
- PHP Warning adding menu
- how to split vertical menu into two columns using walker nav menu
- Customize version different to Live version
- Sub-Items Not Visible in Navigation
- Editing/Removing Secondary Menu from Divi
- Can’t add optional class to menu item when using Walker_Nav_Menu
- Menu Button that link to different pages for unique user?
- Change “login/register” to “useraccount” when a user has logged in
- Question regarding register_nav_menus();
- Making wordpress menu horizontal [closed]
- Theme: Twenty Thirteen Mobile Sliding Menu Doesn’t Bump Content Down
- nav_menu: how to force a subpage switching on the parent menu
- wp_dropdown_nav function to list menu items
- Hardcoding links to wp_nav_menu
- wp_nav_menu() reutrns HTTPS?
- Update nav menu item position programmatically
- Navigational error
- Hide page link in main menu from anonymous users
- load wp_menu dynamically with enquire.js
- How to make a page to not appear in the menu when created?
- custom walker to add iconfont to wp_nav_menu
- wordpress 3.4.2 + wp_nav_menu + chunk theme not working [closed]
- Display Username as parent menu item
- My html data comes after the nav menu renders?
- How to modify menu text in callback function of ‘walker_nav_menu_start_el’ hook
- How to let the role “editor” to control the menu?
- Adding ‘Original’ URL for Custom links
- Menu in widget with yahoo style
- The menu item is not deleted on WordPress
- How to change mobile menu (toggle) icon in WordPress – Full Site Editing?