Skip to content
Docs
Get RestroPress

Filter

rpress_get_item_food_type

Updated
On this page

Filters the food type (such as veg or non-veg) of a menu item.

Runs in RPRESS_Fooditem::get_food_type() with the value of the rpress_food_type post meta. The filter is applied only on the first call for an object, when the value is read from the database. On later calls to the same object the method does not return a value.

Parameters#

ParameterTypeDescription
$food_typestringStored food type slug.
$IDintMenu item ID.

Return value#

string. Food type slug.

Example#

function my_food_type( $food_type, $fooditem_id ) {
	if ( '' === $food_type ) {
		return 'veg';
	}
	return $food_type;
}
add_filter( 'rpress_get_item_food_type', 'my_food_type', 10, 2 );

Notes#

Because the method only returns inside the first-load branch, a second call on the same RPRESS_Fooditem object returns null.

Source#

Applied in:

  • includes/class-rpress-fooditem.php (line 223), in RPRESS_Fooditem::get_food_type()

See also#

Was this page helpful?