Building template packs
On this page
A template pack changes how the RestroPress storefront looks. You register it from your own plugin or theme, say which pack it builds on, and ship only what you change. This guide covers RestroPress 3.5.1, which added parent packs, the layout and component settings, and stable class names. The settings a store owner sees are under RestroPress › Settings › Styles.
What a pack is made of#
A pack has four layers. Use the lightest one that does the job.
- Tokens: colours and fonts, as
--rpc-*CSS custom properties. - Layout: where things go, such as the store header, category navigation, card shape, cart style and the order of the parts above the menu items.
- Components: how shared pieces look, such as card borders, photo size and tab style. RestroPress writes the CSS from these settings.
- Stylesheet and templates: your own CSS, and template files for markup changes the other layers cannot make.
RestroPress registers two packs itself, classic and modern. The active pack is the saved template_pack option. If that pack is not registered, for example because its plugin was deactivated, or if Legacy Ordering Flow is on, RestroPress uses Classic.
Register a pack#
Call rpress_register_template_pack() on the rpress_register_template_packs action. The action fires once, on init at priority 5, after Classic and Modern are registered.
add_action( 'rpress_register_template_packs', function () {
rpress_register_template_pack( array(
'id' => 'harbour',
'label' => __( 'Harbour', 'my-pack' ),
'extends' => 'modern',
'tokens' => array( 'ink' => '#10202B', 'font-display' => "'Fraunces', serif" ),
'layout' => array( 'masthead' => 'cover', 'cart_style' => 'drawer' ),
'components' => array( 'card' => array( 'radius' => '16px' ) ),
) );
} );
The function returns true on success. If id or label is empty it returns false and raises a _doing_it_wrong notice. Registering an id that already exists replaces the earlier pack, so use an id of your own.
Arguments#
| Argument | Default | What it does |
|---|---|---|
id | Empty (required) | Pack key, passed through sanitize_key(). The page body gets the class rp-pack-{id}. |
label | Empty (required) | Name shown in the pack picker. |
description | Empty | Text shown on the picker card. |
version | 1.0.0 | Your version number. With the file's modification time, it forms the stylesheet's cache-busting version. |
preview | Empty | Image URL for the picker card. Without one, a placeholder drawing is shown. |
dir | Empty | Server path of the folder with your template overrides. |
url | Empty | URL of the folder that holds your stylesheet file. |
stylesheet | Empty | Absolute path to your CSS file, or the handle of a style you registered. |
tokens | Empty array | Values for --rpc-* properties, with or without the prefix. |
fonts | Empty | URL of a font stylesheet to load with the pack. |
variants | Empty array | A list of layout variants (key and label). Classic and Modern pass list and grid. RestroPress 3.5.1 does not read this value; the Menu Layout setting is separate from the pack. |
pro | false | Marks a paid pack. The picker shows its card locked unless the rpress_template_pack_entitled filter returns true for it. See below. |
extends | Empty | Id of the parent pack. New in 3.5.1. |
layout | Empty array | The storefront layout your pack recommends. New in 3.5.1. |
components | Empty array | Component settings. New in 3.5.1. |
Paid packs#
The pro argument and its filter control the pack picker. A plugin that sells a pack should also check its own license when it registers, and when the check fails, register only the details the picker needs (id, label, description, preview, version and pro). When a locked pack is the saved choice, the Styles screen tells the store owner that customers are seeing the Classic design, keeps the choice when the settings are saved, and shows a Check license link. Change that link with rpress_template_pack_locked_url.
Parent packs#
With extends, your pack is a child of another pack. These are inherited:
- Templates: your
diris searched first, then each parent's. - Layout: merged key by key, from the oldest parent down to your pack. A list such as
railsorsectionsis replaced as a whole. - Components: merged setting by setting, in the same order.
tokens, fonts and stylesheet are not inherited. Only the active pack's values are used. A pack can name a parent that is registered later. A parent that is not registered ends the chain, and a chain stops at five packs, counting your own. A pack that names itself has no parent.
Check these points if you extend modern:
- You inherit Modern's templates (the list menu item row, list and grid images, the cart item, the category list and the item popup) and its
bandstore header value. - Modern's stylesheet does not load, and its rules are scoped to
body.rp-pack-modern. Test the inherited markup with your own styles. Modern has no component settings. - With
mastheadset toband, RestroPress shows the store card by default only when the active pack id ismodern. Choosecover,striporeditorialfor your pack, or returntruefor your pack id from therpress_mobile_ordering_show_store_cardfilter.
Tokens#
Core styles read these properties. Set any of them in tokens: ink, body, muted, border-subtle, border-strong, surface, panel, page, veg, nonveg, font-body and font-display. Checkout headings use font-head. Some component styles use accent and accent-ink and fall back to the primary colour when they are not set. Other keys are printed too, for use in your own CSS. A value that contains a semicolon is skipped.
The primary colour follows the store owner's Theme Color:
- A
primarytoken, given as a hex colour, applies only while Theme Color is at its default (#ED5575). - Your
primaryandprimary-*tokens are not printed directly. RestroPress works out the shades from the colour in use. On the menu these are--rpc-primary,-hover,-press,-tint,-tint-border,-shadow,-rgb,-text(darkened where needed to read as text on white), and--rpc-on-primary(text on a primary fill). Use them instead of fixed colours. - An
on-primarytoken is kept only while the colour in use matches your pack'sprimary. Otherwise RestroPress picks white or a near-black.
Tokens apply to the menu, the item and time popups, and checkout. The order tracking stylesheet uses its own --rp-track-* properties, so style that screen in your pack stylesheet.
Layout#
The layout in effect is built in this order: core defaults, each parent pack (oldest first), your pack, then the saved storefront_layout option. RestroPress 3.5.1 reads that option but has no settings screen for it. The rpress_storefront_layout filter runs last. Unknown keys and values are dropped.
Layout applies to pages that contain the [fooditems] shortcode or the rpress/food-menu block. It does not apply with Legacy Ordering Flow on.
| Key | Allowed values | Default | Notes |
|---|---|---|---|
masthead | none, band, cover, strip, editorial | none | cover has a cover image area, strip is compact, and editorial is a centred header without the logo or initials mark. none and band add no new header; they leave the existing store card or Modern header behaviour in place. |
nav_style | topbar, sidebar, tabs, accordion, dropdown | sidebar | topbar puts the category bar above the menu from 768px wide. Core has no styles of its own for tabs, accordion or dropdown: they only add a body class. |
nav_media | none, icons, images | none | images adds photo tiles to the category bar. Core adds nothing but a body class for icons. |
columns | 1, 2, 3, 4 | 1 | Menu item card columns. |
card_style | beside, top, overlay, text | beside | Photo beside the text, on top, behind the text, or hidden. |
show_image | true, false | true | false hides menu item photos on the cards. |
cart_style | sidebar, drawer | sidebar | The drawer applies from 1025px wide. |
item_style | modal, side_sheet | modal | The side sheet applies from 768px wide. |
rails | List of popular, order_again, deals | Empty | Rows of menu items, in the order given. |
sections | List of rails, nav, service | rails, nav, service | Order of the parts above the menu items. |
Menu item rows#
popular lists menu items with recorded sales, most sold first. order_again lists menu items from a logged-in customer's completed orders. deals lists menu items with the tag whose slug is deals. Each row shows up to eight published menu items that can be ordered now. A row with no menu items is not printed. Tapping an item in a row opens the same popup as in the menu, and items that are not on that menu page are removed from the row.
The sections value#
Give the parts in the order you want:
'sections' => array( 'service', 'nav', 'rails' ),
service is the row with delivery or pickup, time and search. nav is the category bar. A part you leave out is put back at its default position. The store header always comes first and the menu items come last. When rails is first, the rows span the full width above the menu and cart. Otherwise they print inside the menu column.
The list menu template follows the whole order. The grid templates keep the category bar and service row where they are, and only move the rows: above everything when rails is first, or below the service row when it is not. On wide screens the sidebar keeps its own column and the category bar is hidden, so moving nav shows where that bar is visible, for example with topbar or on phones.
The rpress_menu_section_order filter changes the order at run time. Return all three names; the list template does not print a part that is missing from the filtered result.
Layout body classes#
On menu pages, a value that differs from the core default adds a body class, together with the class rp-sf. Underscores in values become hyphens.
| Key | Body class |
|---|---|
masthead | rp-sf-masthead-cover, rp-sf-masthead-strip, rp-sf-masthead-editorial (none for band) |
nav_style | rp-sf-nav-{value} |
nav_media | rp-sf-media-{value} |
columns | rp-sf-cols-{number} |
card_style | rp-sf-card-{value} |
show_image | rp-sf-noimg when false |
cart_style | rp-sf-cart-drawer |
item_style | rp-sf-item-side-sheet |
rails and sections add no body class.
Components#
The components argument is an array of component names, each with its settings. RestroPress checks the values, merges them through the parent packs, and prints CSS for the active pack on menu pages only (not with Legacy Ordering Flow). The CSS uses !important and loads late, so to change something a component setting controls, change the setting. Every setting is optional.
While the active pack has any component setting, its own or inherited, the storefront uses the list templates even if Menu Layout is set to Grid.
Value types#
- CSS: one CSS value, up to 120 characters. It is rejected if it contains a semicolon, braces, angle brackets, a backslash or the start of a comment, or if it has unmatched parentheses or quotes. HTML tags are stripped.
- px and number: a numeric value, stored as a whole number without a sign. Write
96, not'96px'. Do not use negative numbers.0works like leaving the setting out. - bool: use real
trueorfalse. The value is cast, so the string'false'counts as true. - Choice: one of the listed strings. A choice of
defaultadds no CSS.
Unknown components, unknown settings and invalid values are dropped without a notice.
card#
| Setting | Type or choices | Effect |
|---|---|---|
border, radius, background, padding | CSS | The card box. Setting any of them removes core's inner card box. |
shadow | CSS | Card shadow, kept on hover. |
photo_size | px | Photo size when the photo is beside the text. |
photo_radius | CSS | Photo corner radius. |
photo_ratio | 1/1, 4/3, 16/10 | Photo shape with card_style top. |
photo_side | right, left | left moves a beside photo to the left. |
title_size | px | Menu item name size. |
title_weight, price_weight | number | Font weight. |
title_font, price_font, desc_font | body, display | Uses the matching font token. |
price_size | px | Price size. |
price_color | CSS | Price colour. |
price_first | bool | Price directly under the name, above the description. |
desc | show, hide | hide removes the description from the card. |
desc_lines | number | Maximum description lines. |
desc_italic | bool | Italic description. |
add_button | default, corner, block, ring | corner: a round plus button, on the photo's corner when the photo is beside the text. block: a full-width button along the bottom of the card. ring: a round outlined plus button at the top right of the row (top left in right-to-left layouts). |
stepper | phone, always | always shows the quantity stepper on cards on desktop too. add_button ring shows no card stepper. |
leader | bool | Name, dotted leader and price on one line. On phones the price goes under the name. |
phone | default, rows | rows shows plain rows separated by lines on phones (up to 767px). |
Other components#
| Component and setting | Type or choices | Effect |
|---|---|---|
menu.max_width | px | A centred menu column with this maximum width. |
section.style | default, rules | rules: centred capital headings between two lines, with the category description in italics. |
tabs.style | default, underline, smallcaps | Style of the category bar links. smallcaps puts a dot under the current category. |
tabs.counts | bool | false hides the item counts in the category bar. |
rail.card_width | px | Width of the cards in a menu item row. Phones use a smaller width. |
rail.photo_ratio | 4/3, 16/10, 1/1 | Photo shape in menu item rows. |
rail.bare | bool | Removes the card box in menu item rows. |
rail.plus | bool | Draws a decorative plus on row photos. The whole row card opens the menu item. |
masthead.cover_height | px | Cover height. Phones and headers without a cover image use a smaller height. |
masthead.cover_filter | none, grayscale | Filter on the cover image. |
masthead.monogram_size | px | Size of the logo or initials mark in the cover header. |
masthead.name_size | px | Store name size on the store card inside a cover, strip or editorial header. |
masthead.meta | chips, text | text shows the status and store details as plain text instead of chips. |
service.style | default, segmented | segmented: delivery and pickup as a rounded switch, with matching time and search fields. |
sheet.groups | default, cards | cards boxes each option group in the item popup. |
sheet.cta_case | default, none | none stops the popup's main button text being capitalised by CSS. |
allergens.style | default, mono, text | mono uses neutral colours for allergen codes and the popup's allergen box. text shows card codes as plain text. |
The ring button, the rules headings and the smallcaps dot use --rpc-accent when your pack sets an accent token, and the primary colour otherwise. On a dark pack, set accent so a dark Theme Color stays visible.
Stylesheet#
Your stylesheet loads after core's on the menu, checkout and order tracking screens while your pack is active. When you give a file path, also set url: RestroPress builds the address from url and the file name only, so the file must sit directly in that folder. When you give a style handle, register it before RestroPress enqueues its styles on wp_enqueue_scripts (priority 10). With Disable RestroPress Styles on, RestroPress does not load the pack's stylesheet, tokens or fonts.
Scope every rule to your pack:
body.rp-pack-harbour .rpress-menu-v2 .rp-card__title { letter-spacing: -0.01em; }
Stable class names#
RestroPress 3.5.1 added these names for packs to target. They are intended to stay the same across releases. Other class names come from older templates and may change.
| Class | What it marks |
|---|---|
rp-card | A menu item card. |
rp-card__media | The photo and Add button column in list cards. |
rp-card__photo | The photo holder in the core list and grid image templates. Modern's image templates, and so packs that inherit them, do not print it. |
rp-card__text, rp-card__title, rp-card__desc, rp-card__price, rp-card__add | Text block, name, description, price and Add button area. |
rp-menu-section | A category heading block on the menu, with rp-menu-section__title and, when the category has a description, rp-menu-section__desc. |
rp-menu-nav | The category bar wrapper in the list menu template. |
rp-service-row | The delivery or pickup, time and search row, with rp-service-row__service, rp-service-row__time and rp-service-row__search. The first two are not printed with Legacy Ordering Flow. |
Template overrides#
For markup changes, set dir and copy only the templates you change into it, keeping their paths, for example list/single.php. For templates loaded with rpress_get_template_part() while a pack other than Classic is active, RestroPress first looks for a pack-specific copy at {pack-id}/{template} in each location, then for the plain file. Locations are searched in this order:
- Child theme
restropress/folder. - Parent theme
restropress/folder. - Your pack's
dir. - Each parent pack's
dir, nearest first. - The RestroPress
templates/folder.
So a theme can override one file for one pack at yourtheme/restropress/{pack-id}/{template}. A theme file at the plain path also takes priority over the same file in your pack. Only the active pack's id is used for the pack-specific path, not a parent's. A file that RestroPress includes directly, without the template loader, cannot be overridden this way.
Copied templates do not receive core fixes. Compare the @version line, where a file has one, and the file itself after each RestroPress update. In 3.5.1 the list menu template changed to print its parts in the sections order, so an older copy does not follow that value.
Hooks#
| Hook | Type and arguments | Use |
|---|---|---|
rpress_register_template_packs | Action | Register packs. |
rpress_template_pack_entitled | Filter: bool, pack | Unlock a pro pack in the picker. Default false. |
rpress_template_pack_locked_url | Filter: URL, pack | Link in the notice for a locked saved pack. |
rpress_storefront_layout_schema | Filter: schema | Layout keys and allowed values. Values are checked at registration, so add this before packs register. |
rpress_storefront_layout | Filter: layout, active pack | Change the layout in effect. |
rpress_pack_component_schema | Filter: schema | Add component settings, typed css, px, int, bool or an array of choices. Add it before packs register. You write the CSS for your own settings. |
rpress_pack_components | Filter: components, pack | Change the merged component settings. The result is checked again. |
rpress_menu_section_order | Filter: order | Order of rails, nav and service. |
rpress_menu_page_top | Action | Print above the menu. |
rpress_menu_section_rails | Action | Fired by the menu templates where the menu item rows go when they are not first. Keep it in a copied menu template. |
rpress_storefront_cover_image | Filter: URL | Cover image for the cover header. The default comes from the Store Cover Image setting. |
rpress_category_image_url | Filter: URL, term ID | Category tile image. Core uses the term's thumbnail_id, then the photo of a menu item in that category, and caches the result for up to an hour in the object cache. Without an image the tile shows the first letter. |
rpress_storefront_rail_items | Filter: menu item IDs, row key | Menu items in a row. |
rpress_storefront_rail_limit | Filter: number, row key | Menu items per row. Default 8. |
rpress_storefront_rail_title | Filter: title, row key | Row heading. |
rpress_storefront_deals_tag | Filter: slug | Tag used by the Deals row. Default deals. |
rpress_mobile_ordering_show_store_card | Filter: bool, pack ID | Show the standalone store card above the menu. |
rpress_store_header_delivery_chip | Filter: text, context | Delivery text in the store header. Context is header or store_card. Return an empty string for no chip. |
rpress_template_paths | Filter: paths keyed by priority | Template search locations. |
Functions#
rpress_get_template_packs(): all registered packs.rpress_get_active_template_pack(): the active pack.rpress_get_storefront_layout(): the layout in effect.rpress_get_pack_components( $pack = null ): component settings in effect, for the active pack by default.rpress_menu_section_order(): the order of the parts above the menu items. It uses the layout of the current menu page.rpress_storefront_renders_masthead():truewhen core prints acover,striporeditorialheader on the current page. A pack that prints its own header should then print nothing.
A working example#
RestroPress includes an example pack in its docs/example-pack/ folder. The version below is based on it, with one addition, 'nav_style' => 'topbar', so that the underlined tabs and the position of the category bar also show on desktop. Without that line the sidebar is used on wide screens.
To try it, create wp-content/plugins/rp-example-pack/ with the two files below (or copy docs/example-pack/ into wp-content/plugins/), activate the plugin, then choose Example under RestroPress › Settings › Styles and save.
example-pack.php
<?php
/**
* Plugin Name: RestroPress Example Pack
* Description: A minimal RestroPress template pack.
* Version: 1.0.0
* Requires Plugins: restropress
* Text Domain: rp-example-pack
*/
defined( 'ABSPATH' ) || exit;
add_action( 'rpress_register_template_packs', function () {
rpress_register_template_pack( array(
'id' => 'example',
'label' => __( 'Example', 'rp-example-pack' ),
'description' => __( 'A calm, rounded pack built on Modern.', 'rp-example-pack' ),
'version' => '1.0.0',
'extends' => 'modern',
'fonts' => 'https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,600;9..40,700&display=swap',
'tokens' => array(
'ink' => '#15232D',
'body' => '#3B4A54',
'muted' => '#6B7780',
'border-subtle' => '#E6ECEF',
'border-strong' => '#CBD5DA',
'surface' => '#F2F6F8',
'font-body' => "'DM Sans', sans-serif",
'font-display' => "'DM Sans', sans-serif",
),
'layout' => array(
'masthead' => 'cover',
'nav_style' => 'topbar',
'cart_style' => 'drawer',
'item_style' => 'side_sheet',
'rails' => array( 'popular' ),
'sections' => array( 'service', 'nav', 'rails' ),
),
'components' => array(
'card' => array(
'radius' => '16px',
'border' => '1px solid var(--rpc-border-subtle)',
'padding' => '16px',
'photo_size' => 96,
'add_button' => 'corner',
'price_first' => true,
),
'tabs' => array( 'style' => 'underline' ),
'service' => array( 'style' => 'segmented' ),
),
'stylesheet' => __DIR__ . '/example-pack.css',
'url' => plugins_url( '', __FILE__ ),
) );
} );
example-pack.css
body.rp-pack-example .rpress-menu-v2 .rp-menu-section__title {
letter-spacing: -0.01em;
}
body.rp-pack-example .rpress-menu-v2 .rp-card__price {
color: var(--rpc-primary-press, var(--rpc-primary));
}

Checklist before release#
- Scope all CSS to
body.rp-pack-{id}. - Test phones (up to 767px), tablets and desktop. Some layout values start at 768px and the cart drawer at 1025px.
- Check the menu, item popup, cart, checkout and order tracking.
- Try a Theme Color other than the default, including a light one and a dark one.
- Prefer tokens, layout and components. Copy templates only when you need to.
For other extension points, see the actions and filters references.
