Most of users use wp_nav_menu to output the menu in a theme, then you could make use of the callback function that is passed in the arguments array.
wp_nav_menu( array( 'fallback_cb' => 'wp_page_menu' ) );
wp_page_menu
is the default value for the callback function.
Looking further, wp_page_menu has an exclude
key in its arguments array.
wp_page_menu( array( 'exclude' => '' ) );
You can add a filter to it by adding comma separated values to the exclude
key in the arguments array.
function my_cb_function( $args ) {
$args['exclude'] .= '10,20,30' // comma separated IDs
return $args;
}
add_filter( 'wp_page_menu_args', 'my_cb_function', 999, 1 );
Related Posts:
- add_menu_page() with different name for first submenu item
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- Change the_title() of a page dynamically
- How do I programatically insert a new menu item?
- Add Dividers or Separators Between Nav Menu Items
- Nav Menu meta failing to import
- Overwriting Core WordPress Functions with Plugins
- Some nav-menu filters do nothing
- Determine which theme location a wp_get_nav_menu_items is for
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Hook event for upload image in the menu
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- How do I approach removing menu items on the fly based on settings in my plugin?
- What is the difference between current_page_parent and current_page_ancestor?
- Delete a specific item menu when I deactivate my plugin
- Create a Page via plugin
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- Header Button Chance Polylang Elementor
- PHP 7 – Class Method Compatibility Issue
- How to add pages to custom menus on the fly [duplicate]
- How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?
- Add notification bubble notice in navigation using transients
- Get Current Menu Location inside Nav_Walker
- Adding custom fields to WordPress nav menus
- Sub Menu content is being duplicated
- Plugin menu addition in multisite
- Remove unwanted elements for a wp_nav_menu
- Is this best practice for Dynamically adding items to WordPress menus?
- How to remove or add submenu item on plugin activate or deactive
- Custom code for WordPress dynamic menu
- How do I access the menus produced by Dashboard > Appearance > Menus
- wordpress add_submenu_page adds broken link
- WP Enqueue style on all plug-in pages
- Add child pages to submenu automatically
- Customize existing menu item
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- Issue with plugin sub menu and pages
- How to add Plugin functionality in WordPress Frontend Menus
- WP_NAV_MENU filter targets all menus
- How do I add a menu item to a Pods admin menu?
- Add user managable titles to custom menus?
- How to create archive page to add in menu
- How to show only the last two categories in a menu?
- Always hide a page from the menu
- remove different admin menu for specific users
- How to get an array out of a nav menu if it’s a plugin?
- What happens when you create/edit a menu
- Plugin admin list pages as submenu
- Adding parent custom post type menu option
- Create and style menu
- Change the class of wordpress menu
- Invalid Menu Items
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Custom Nav Walker $item->url producing malformed hyperlinks
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- WP 3.3 How to Add Menu Items to the Admin Bar?
- Unit tests – Dealing with dependencies
- Should I create a theme or a plugin?
- How to change wordpress post title?
- comment_email hook doesn’t seem to work for comment editor field
- How can I add a field to make link nofollow to the WordPress Link Inspector Window?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- How to show large image in checkout page using WP Ecommerce plugin [closed]
- settings_fields() doesn’t work for other roles except admin
- Subscribe to author?
- how to make custom bulk actions for a WP_List_Table (core class)
- Get name and email of current unregistered user, who has recently submitted name and email in comment form?
- Auto save permalink setting page with the plugin activation
- creating custom function to log actions in plugin
- Show custom data instead of 404
- What’s the right way to instantiate new blocks and/or the plugin itself in toto when using wppb architecture?
- Serve text/html from wp-json API via WPEngine, headers not being set properly
- wp_schedule_event seems to be being added twice
- What happens when two or more plugins use the same hook?
- Custom Stylesheet instead of Inline CSS for WordPress Customizer API Overrides
- AJAX button with success callback. (Titan Framework)
- Information on plugin adding text when a post, page, or other such is displayed
- Cannot stop wpautop from messing up my plug-in output
- Displaying custom content from a plugin within the active theme
- product-attribute-slug-is-too-long-28-characters-max
- Custom plugin & calling REST api of wordpress instance the plugins is running on
- Add variables from rewrite rules to query var
- Show list of categories that has posts with different taxonomies
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- How do I specify where to save the debug.log?
- What is the source of the $post_id in a hook argument?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Use content filter on the post that is password-protected
- How to fetch the post content from the wordpress editor before it can be saved(published)?
- How does one set cookies in WordPress without getting the ‘headers not sent’ error? within WP
- Filter the_content() to add custom figure tags
- Glyphicons Dont Show in WordPress Plugin Only
- Change the search results header from plugin
- Installing plugins on installation/activation
- Add query string variables to all hyperlinks URL matching a specified domain
- Is there such a thing as a WordPress console?
- Anyway to prevent admin from seeing other admin’s product?