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.
- $posts = apply_filters( 'nav_menu_items_{$post_type_name}', $posts, $args, $post_type );
- if ( !empty( $posts ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the nav_menu_items_<post_type_name> callback
- function filter_nav_menu_items_post_type_name( $posts, $args, $post_type ) {
- // make filter magic happen here...
- return $posts;
- };
- // add the filter
- 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.
- // remove the filter
- 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
- $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );