Skip to content
Docs
Get RestroPress

Filter

rpress_fooditems_query

Updated
On this page

Filters the WP_Query arguments for the menu items of a category.

Runs once per category in the menu list templates. The query is built from the shortcode attributes: post type fooditem, published, no paging, ordering, a tax_query on food-category for the current slug and an optional post__in. The result is passed to a new WP_Query.

Parameters#

ParameterTypeDescription
$prepared_queryarrayWP_Query arguments for the current category.
$attsarrayThe shortcode attributes.

Return value#

array. The WP_Query arguments.

Example#

function my_fooditems_query( $prepared_query, $atts ) {
	$prepared_query['post__not_in'] = array_map( 'absint', (array) get_option( 'my_hidden_menu_items', array() ) );
	return $prepared_query;
}
add_filter( 'rpress_fooditems_query', 'my_fooditems_query', 10, 2 );

Notes#

Runs inside a loop over categories, so keep the callback fast.

Source#

Applied in:

  • includes/features/block-storefront/functions.php (line 412), in rpress_block_storefront_category_items()
  • templates/fooditem/fooditems.php (line 74)
  • templates/fooditem/fooditems.php (line 120)
  • templates/grid/fooditems.php (line 104)
  • templates/list/fooditems.php (line 101)

See also#

Was this page helpful?