I’m using the built in menu manager to create my menues and I disaply them by using wp_nav_menu()
.
I’m wondering, is it possible to remove certain menu items from being displayed based on some specific condition?
I’m using the built in menu manager to create my menues and I disaply them by using wp_nav_menu()
.
I’m wondering, is it possible to remove certain menu items from being displayed based on some specific condition?
You must be logged in to post a comment.
Use the wp_nav_menu_objects filter to adjust the menu items using whatever conditions you like. The filter will receive and return an array of the menu items.
Instead of using
wp_nav_menu()
, you can try usingwp_get_nav_menu_items
which will return a list of menu items, then you can have conditional statements to pick an choose which to display.http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items
if our menu is pages you can use Exclude Pages from List
Just use the id of pages sepearated b comma
UPDATE
Try this one
Go to Appearance -> Menu and then from there click “Create Menu” then add menus that you want to include and you can set a Location for menus with this code below try to explore