Skip to content
WXP Plugins

Plugins

WXP Restaurant Menu

WXP Opening Times

WXP Local Events

WXP Restaurant Reservations

Demo

Pricing

Support

Docs

FAQ

Buy

Menu

Plugins

- WXP Restaurant Menu

- WXP Opening Times

- WXP Local Events

- WXP Restaurant Reservations

Demo

Pricing

Support

- Docs

- FAQ

Buy

WXP Opening Times

8
  • Installation
    • Installing WXP Opening Times
  • Basic operations
    • Creating your (first) schedule
    • Setting exceptions
  • For developers
    • Filter- and action hooks
    • Twig templates
    • WXP Opening Times shortcodes
  • Jewish and Islamic holidays
    • Installation
      • Installing WXP Opening Times: Jewish and Islamic holidays
    • For developers
      • Jewish and Islamic holidays: for developers

WXP Restaurant Menu

7
  • Installation
    • Installing WXP Restaurant Menu
  • Basic operations
    • Understanding the concept
    • The Settings for the WXP Restaurant Menu Plugin
    • The Icon menu
  • For developers
    • Filter- and action hooks
    • Twig templates
    • WXP Restaurant Menu shortcodes

WXP Local Events

8
  • Installation
    • Installing WXP Local Events
  • For developers
    • Filter- and action hooks
    • Twig templates
    • WXP Local Events shortcodes
  • Local Events for WooCommerce
    • Installation
      • Installing WXP Local Events for WooCommerce
    • For developers
      • Local Events for WooCommerce: for developers
  • Events Feed
    • Installation
      • Installing WXP Events Feed
    • For developers
      • Events Feed: for developers

WXP Restaurant Reservations

6
  • Installation
    • Installing WXP Restaurant Reservations
  • For developers
    • Filter- and action hooks
    • Twig templates
    • WXP Restaurant Reservations shortcodes
  • Rooms
    • Installation
      • Installing WXP Restaurant Bookings: Rooms
    • For developers
      • Rooms: for developers

General Developer Information

1
  • Twig
    • Twig templates in the WXP plugins

WXP Agency Kit

1
  • WXP Agency Kit: demo content from the command line
View Categories
  • Home
  • Documentation
  • General Developer Information
  • Twig
  • Twig templates in the WXP plugins

Twig templates in the WXP plugins

2 min read

0:00 / 3:46
  • View as Markdown Open this page as plain Markdown (opens in a new tab)
  • Open in ChatGPT Ask questions about this page (opens in a new tab)
  • Open in Claude Ask questions about this page (opens in a new tab)
  • Open in Google AI Studio Ask questions about this page (Google account required) (opens in a new tab)

Twig is a template language for PHP. A Twig template looks like HTML, with a few extra tags to print values and to repeat or hide parts. All four WXP plugins use it to build the HTML of their menus, opening hours, events and booking forms. Because the layout is in a template and not in PHP code, you can change how a plugin looks without touching the plugin.

The basics #

A template is a text file that ends with .html.twig. Three kinds of tags are enough for most changes:

  • {{ ... }} prints a value, for example {{ item.name }}.
  • {% ... %} does something, such as a loop or a condition.
  • {# ... #} is a comment that is not printed.
{# Print the items of a category #}
<ul>
{% for item in category.items %}
	<li>
		{{ item.name }}
		{% if item.price %}<span class="price">{{ item.price }}</span>{% endif %}
	</li>
{% endfor %}
</ul>

The names you can use, such as item or category in the example above, depend on the plugin and on the template. The data a template receives is called its context. You can add your own values to the context with the ..._template_context filter of each plugin (see the guide Filter- and action hooks of that plugin).

How the plugins use Twig #

  • One template per layout. A style such as cards, compact or elegant is one template file. The template setting of a shortcode, block or widget chooses the file.
  • Partials. Files that start with an underscore, such as _item.html.twig or _base.html.twig, are pieces that other templates include. They are not layouts to choose.
  • Escaping. Every value is escaped as HTML automatically, so text with a < or a quote cannot break the page. You only need to think about this when you print HTML on purpose.
  • Missing values. A value that does not exist prints nothing, and it does not cause an error.
  • Errors. When a template has a mistake, only that block is affected and the rest of the page keeps working. Users who can edit the theme see a short error message in its place; other visitors see nothing.
  • No conflicts. Each plugin carries its own copy of Twig, with a private name, so it does not clash with another plugin or theme that also uses Twig.

Where the plugins look for templates #

A plugin looks for a template in three places, in this order. The first file that is found is used:

  • the folder of the plugin in your child theme,
  • the folder of the plugin in your parent theme,
  • the templates folder inside the plugin.
Plugin Folder in your theme
WXP Restaurant Menu wxp-restaurant-menu/
WXP Opening Times wxp-opening-times/
WXP Local Events wxp-local-events/
WXP Restaurant Reservations wxp-restaurant-reservations/

So to change a layout, copy the file from the templates folder of the plugin to the folder above in your child theme and edit the copy. Never edit the files inside the plugin: an update would replace them. You only have to copy the files you want to change; for all the others the plugin uses its own.

Make your own layout #

  • Copy a template that is close to what you want, for example cards.html.twig, into the folder of the plugin in your child theme.
  • Give it a new name, for example my-menu.html.twig.
  • Use the name without .html.twig in the template parameter of the shortcode: [wxp_menu template="my-menu"].

If you copy a file with the same name as a plugin file, yours replaces it for the whole site. A name that does not exist falls back to the default template of that plugin.

More information #

  • Each plugin has a guide Filter- and action hooks with the filters for template folders, template data and the Twig cache.
  • Each plugin has a guide with the shortcodes and their template parameter.
  • The Twig language itself is described on the website of Twig (twig.symfony.com), in the chapter Twig for Template Designers.
Updated on October 30, 2026

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
Twig templates in the WXP pluginsTwig templates in the WXP plugins

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • The basics
  • How the plugins use Twig
  • Where the plugins look for templates
  • Make your own layout
  • More information
WXP Plugins

Demo

Pricing

© 2026 WXP Plugins. All prices are in euro, excluding VAT.

WXPPlugins is a brand of WP Digital Marketing - The Netherlands - Chamber of Commerce (KvK) 75580152