nav_menu_items_(post_type_name)
Filters the posts displayed in the 'View All' tab of the current post type's menu items meta box.
The dynamic portion of the hook name, $post_type_name, refers to the slug of the current post type.
Possible hook names include:
Usage
add_filter( 'nav_menu_items_(post_type_name)', 'wp_kama_nav_menu_items_post_type_name_filter', 10, 3 ); /** * Function for `nav_menu_items_(post_type_name)` filter-hook. * * @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but can also contain "fake" post objects to represent other menu items. * @param array $args An array of `WP_Query` arguments. * @param WP_Post_Type $post_type The current post type object for this menu item meta box. * * @return object[] */ function wp_kama_nav_menu_items_post_type_name_filter( $posts, $args, $post_type ){ // filter... return $posts; }
- $posts(object[])
- The posts for the current post type. Mostly WP_Post objects, but can also contain "fake" post objects to represent other menu items.
- $args(array)
- An array of WP_Query arguments.
- $post_type(WP_Post_Type)
- The current post type object for this menu item meta box.
Changelog
Since 3.2.0 | Introduced. |
Since 4.6.0 | Converted the $post_type parameter to accept a WP_Post_Type object. |
Where the hook is called
nav_menu_items_(post_type_name)
wp-admin/includes/nav-menu.php 782-787
$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );