Filter
rpress_menu_schema_item
On this page
Filters one MenuItem in the menu schema.
Runs at the end of RPRESS_Menu_Schema::menu_item() for each menu item (a fooditem post) that has a title. The array contains @type, name and, when available, description, image, offers and suitableForDiet. Returning an empty array removes nothing structurally, so unset keys instead of emptying the array.
Available since RestroPress 3.5.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$item | array | MenuItem schema array. |
$post | WP_Post | Menu item post. |
Return value#
array. MenuItem schema array.
Example#
function my_menu_schema_item( $item, $post ) {
$calories = get_post_meta( $post->ID, 'my_calories', true );
if ( $calories ) {
$item['nutrition'] = array(
'@type' => 'NutritionInformation',
'calories' => $calories . ' calories',
);
}
return $item;
}
add_filter( 'rpress_menu_schema_item', 'my_menu_schema_item', 10, 2 );
Source#
Applied in:
includes/features/qr-schema/class-rpress-menu-schema.php(line 488), inRPRESS_Menu_Schema::menu_item()
See also#
Was this page helpful?
