Skip to main content
Became Hot Network Question
edited tags; edited tags
Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147
Source Link

In WordPress, I want to use code to filter out one menu item (page) from displaying when I call wp_nav_menu() function

Scenario I have three pages namely John James and Jessica. The Jessica page ID is 666 and I want to filter it out so that it DOES NOT show in the menu. I need help with a simple code similar to the one pasted below, that will help me achieve that. I have deliberately not registered any menu location in my function.php file.

function remove_jessica_page(){
    #
    wp_nav_menu(
        array(
            'exclude'=> 666 // exclude Jessica page from  menu
        ) 
    );
}
apply_filters('wp_nav_menu_items','remove_thankyou_page');