bellows_auto_posts_query_args

Knowledgebase Docs » Bellows
USEFUL? 3

bellows_auto_posts_query_args

This filter allows you to filter the get_posts() query arguments for Post Hierarchy Autopopulation menus

$query_args
An array of query arguments to be passed to get_posts(). The filter callback should return $query_args. For a full list of parameters that can be passed, please see The WordPress Codex: WP Query Parameters

Example: Show public private posts to logged in users

function bam_show_private_posts( $query_args ){
	if ( is_user_logged_in() ) {
		$query_args['post_status'] = array( 'publish', 'private' );
	}
	return $query_args;
}
add_filter( 'bellows_auto_posts_query_args' , 'bam_show_private_posts' );

Example: Exclude post 50 from menu

function bam_exclude_posts( $query_args ){
	$query_args['exclude'] = 50; //array( 50 , 79 );
	return $query_args;
}
add_filter( 'bellows_auto_posts_query_args' , 'bam_exclude_posts' );