[wp-trac] [WordPress Trac] #33955: get_posts() menu args filter
WordPress Trac
noreply at wordpress.org
Tue Sep 22 06:37:16 UTC 2015
#33955: get_posts() menu args filter
------------------------------+-----------------------------
Reporter: sebastian.pisula | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version:
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
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;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33955>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list