Filter
rpress_fooditem_class
On this page
Filters the main CSS class of a menu item card.
Runs in the single item templates for the fooditem, grid, list and modern layouts. The returned string is added to the class attribute of the card wrapper along with layout and state classes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$class | string | The CSS class, by default rpress_fooditem. |
$fooditem_id | int | ID of the menu item. |
$atts | array | The shortcode attributes of the current list. |
$i | int | Position of the item in its category, starting at 1. |
Return value#
string. The class string.
Example#
function my_fooditem_class( $class, $fooditem_id, $atts, $i ) {
if ( has_term( 'specials', 'food-category', $fooditem_id ) ) {
$class .= ' my-special';
}
return $class;
}
add_filter( 'rpress_fooditem_class', 'my_fooditem_class', 10, 4 );
Notes#
In the modern template pack each class goes through sanitize_html_class(), which strips spaces, so return a single class name there.
Source#
Applied in:
templates/fooditem/single.php(line 29)templates/grid/single.php(line 61)templates/list/single.php(line 41)templates/packs/modern/list/single.php(line 41)
See also#
Was this page helpful?
