Make WordPress Core

06/25/2017 07:36:45 PM (7 years ago)

Docs: Add full documentation for arguments accepted by wp_get_nav_menu_items().

Also provide differentiation between arguments as passed to get_posts() vs used for ordering outputted menu items.

By and large, arguments in the $args array are intended to directly affect how nav_menu_item posts are retrieved. When the default ARRAY_A is used for 'output', the 'order' and 'orderby' arguments are essentially ignored, instead giving preference to a hard-coded order of 'ASC' and an orderby value derived from the non-get_posts() argument 'output_key'.

Fixes #15533.

1 edited


  • trunk/src/wp-includes/nav-menu.php

    r40676 r40942  
    577  * Return all menu items of a navigation menu.
     577 * Retrieves all menu items of a navigation menu.
     578 *
     579 * Note: Most arguments passed to the `$args` parameter – save for 'output_key' – are
     580 * specifically for retrieving nav_menu_item posts from get_posts() and may only
     581 * indirectly affect the ultimate ordering and content of the resulting nav menu
     582 * items that get returned from this function.
    578583 *
    579584 * @since 3.0.0
    583588 *
    584589 * @param string $menu Menu name, ID, or slug.
    585  * @param array  $args Optional. Arguments to pass to get_posts().
     590 * @param array  $args {
     591 *     Optional. Arguments to pass to get_posts().
     592 *
     593 *     @type string $order       How to order nav menu items as queried with get_posts(). Will be ignored
     594 *                               if 'output' is ARRAY_A. Default 'ASC'.
     595 *     @type string $orderby     Field to order menu items by as retrieved from get_posts(). Supply an orderby
     596 *                               field via 'output_key' to affect the output order of nav menu items.
     597 *                               Default 'menu_order'.
     598 *     @type string $post_type   Menu items post type. Default 'nav_menu_item'.
     599 *     @type string $post_status Menu items post status. Default 'publish'.
     600 *     @type string $output      How to order outputted menu items. Default ARRAY_A.
     601 *     @type string $output_key  Key to use for ordering the actual menu items that get returned. Note that
     602 *                               that is not a get_posts() argument and will only affect output of menu items
     603 *                               processed in this function. Default 'menu_order'.
     604 *     @type bool   $nopaging    Whether to retrieve all menu items (true) or paginate (false). Default true.
     605 * }
    586606 * @return false|array $items Array of menu items, otherwise false.
    587607 */
Note: See TracChangeset for help on using the changeset viewer.