Skip to content
Docs
Get RestroPress

Filter

rpress_fooditem_class

Updated
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#

ParameterTypeDescription
$classstringThe CSS class, by default rpress_fooditem.
$fooditem_idintID of the menu item.
$attsarrayThe shortcode attributes of the current list.
$iintPosition 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?