Skip to content
Docs
Get RestroPress

Filter

rpress_storefront_rail_items

Updated
On this page

Filters the menu item IDs shown on a storefront rail.

Applied at the end of rpress_storefront_rail_items(): popular lists best sellers, deals lists tagged items, and order_again lists the logged-in customer's past items. Core has already removed unpublished and unavailable items; IDs you add are not checked again. An empty list hides the rail.

Available since RestroPress 3.5.1.

Parameters#

ParameterTypeDescription
$idsint[]Menu item IDs.
$railstringRail key: 'popular', 'order_again' or 'deals'.

Return value#

int[]. Menu item IDs. They are passed through absint().

Example#

add_filter( 'rpress_storefront_rail_items', 'my_rail_items', 10, 2 );
function my_rail_items( $ids, $rail ) {
	if ( 'popular' === $rail && 'publish' === get_post_status( 123 ) ) {
		array_unshift( $ids, 123 );
		$ids = array_unique( $ids );
	}
	return $ids;
}

Source#

Applied in:

  • includes/features/storefront-layout/functions.php (line 418), in rpress_storefront_rail_items()

See also#

Was this page helpful?