nav_menu_items_{$post_type_name} WordPress Filter Hook

The nav_menu_items_{$post_type_name} hook is used to add custom items to a navigation menu. This hook is called when a menu is being generated for a specific post type.

apply_filters( "nav_menu_items_{$post_type_name}", object[] $posts, array $args, WP_Post_Type $post_type ) #

Filters the posts displayed in the ‘View All’ tab of the current post type’s menu items meta box.


Description

The dynamic portion of the hook name, $post_type_name, refers to the slug of the current post type.

Possible hook names include:

  • nav_menu_items_post
  • nav_menu_items_page

Top ↑

See also


Top ↑

Parameters

$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.


Top ↑

Source

File: wp-admin/includes/nav-menu.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.6.0Converted the $post_type parameter to accept a WP_Post_Type object.
3.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.