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:
Использование
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_Postobjects, but can also contain "fake" post objects to represent other menu items. - $args(массив)
- An array of
WP_Queryarguments. - $post_type(WP_Post_Type)
- The current post type object for this menu item meta box.
Список изменений
| С версии 3.2.0 | Введена. |
| С версии 4.6.0 | Converted the $post_type parameter to accept a WP_Post_Type object. |
Где вызывается хук
nav_menu_items_(post_type_name)
wp-admin/includes/nav-menu.php 799-804
$posts = apply_filters(
"nav_menu_items_{$post_type_name}",
$posts,
$args,
$post_type
);