Opened 10 years ago
Last modified 6 years ago
#33955 new enhancement
get_posts() menu args filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Menus | Keywords: | has-patch |
| Focuses: | Cc: |
Description
Before I get menu items by get_posts() I can't filter args (Example: I want ignore item of menu for not logged users)
add_filter( 'wp_get_nav_menu_items_args', 'wp_get_nav_menu_items_args', 10, 3 );
function wp_get_nav_menu_items_args( $args, $menu, $items )
{
if ( ! is_user_logged_in()) {
if (( $key = array_search( 2778, $items ) ) !== false) {
unset( $items[$key] );
}
$args['include'] = implode( ',', $items );
}
return $args;
}
Attachments (3)
Change History (7)
Note: See
TracTickets for help on using
tickets.
Did you create this patch against trunk? Doesn't look like it.
I'd suggest using
svn difforgit patch --no-prefixagainst trunk to also remove those IntelliJ/PhpStorm headers.