Custom Templates

Overview

If you are a developer, or an advanced WordPress user then there are a whole heap of other customisations you can make to the plugin by using Custom Templates.

When a user requests a page that is controlled by the plugin, the plugin will first check which template file should be used to serve the page to the user.  By default, the plugin uses templates that are stored in the plugin itself.  However, if you wish, you can instruct the plugin to load your own Custom Templates instead. The plugin uses the following templates:

 

Product Template

This is the template that is served on a single Product page, eg: /tickets/the-lion-king/.

Product Archive Template

This template builds a grid of products. By default, it will exist on /tickets/, however you may instead choose to serve this on your homepage, by changing the setting in WordPress.  This can be changed using the dropdown selection in Settings > Reading > Front Page

Product Category Page Template

This template presents a grid of products, in the same way as the Product Archive Template, however this template is served on a Product Category taxonomy page, such as /whats-on/musicals/. 

Venue Page Template

This is the template that is served on a single Venue page, eg: /venues/lyceum-theatre/.

Venue Archive Template

This template builds a grid of venues. By default it will exist on /venues/.

 

 

Default Plugin Templates

You can set which template files the plugin uses under Theatre Tickets > Advanced Settings.

The plugin will first look in your theme directory for templates. If it does not find any files with matching file names in your theme the plugin will fallback to the template files packaged with the plugin.

 

Finding the default templates

When creating a custom template you may want to start by duplicating one of the default templates.  The default templates can be found in the plugin’s directory in the ‘templates’ folder. Make sure you do not edit the plugin files themselves, or your changes will get overwritten when the plugin updates.  Instead, copy the template you want to customise and paste it into your theme.

Plugin templates directory: /wp-content/plugins/ltd-tickets/templates

 

 

Setting Custom Templates

After you have created a copy of an existing template file, or written a new custom template, you just need to add it into your active theme directory. To help keep templates separate from your other theme files, create a new directory called something like ‘templates’ and place the files in there.

Once you have added the templates to your theme, navigate to the Advanced Settings tab of the plugin and update the template path with the location of the file in your theme.  If you have placed the custom template file in a folder called templates (see above), then you need to include ‘templates’ in the path:

Great – that’s it! The plugin will now use your custom template file.  By making changes to the template file in your theme you can alter the layout and content of the plugin templates without having any impact on the operation of the plugin.

The next thing you’ll want to do is check out the hook functions for adding plugin content to your templates.

We recommend duplicating the existing templates and moving copies into your theme rather than writing templates from scratch.