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.

Description

apply_filters( 'nav_menu_items_<post_type_name>', (array) $posts, (array) $args, (WP_Post_Type) $post_type ); 

The dynamic portion(s) of the hook name refer to the slug of the current post type.

Parameters (3)

0. $posts (array)
The posts for the current post type.
1. $args (array)
An array of WP_Query arguments.
2. $post_type (WP_Post_Type)
The current post type object for this menu item meta box.

Usage

To run the hook, copy the example below.
  1. $posts = apply_filters( 'nav_menu_items_{$post_type_name}', $posts, $args, $post_type ); 
  2.  
  3. if ( !empty( $posts ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the nav_menu_items_<post_type_name> callback 
  2. function filter_nav_menu_items_post_type_name( $posts, $args, $post_type ) { 
  3. // make filter magic happen here... 
  4. return $posts
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "nav_menu_items_{$post_type_name}", 'filter_nav_menu_items_post_type_name', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "nav_menu_items_{$post_type_name}", 'filter_nav_menu_items_post_type_name', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-admin/includes/nav-menu.php  
  1. $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );