Documentation, Reference Materials and Tutorials for Envira Gallery
How to Create a Custom Template for Galleries
Would you like to create a custom template to display your Envira galleries? You can create your own PHP page templates on your theme for Envira. This tutorial will walk you through how to create a custom page template for your Envira galleries.
This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to create a custom template to display your Envira galleries on a standalone link you’ll first need to create a child theme for your WordPress theme.
We recommend using a child theme for any edits you wish to make to your theme. This ensures that if the theme pushes out an update, you’ll not lose any changes you’ve made to your theme.
Next, navigate to Appearance » Themes and activate your new child theme.
Create the Custom Template
Now that your child theme is activated, we can create our custom page template.
In this example, we’re going to copy the page.php inside the WordPress Twenty Seventeen theme and use this for our Envira galleries custom template following these steps:
Open the /wp-content/themes/twentyseventeen theme directory.
Open the page.php template from the parent’s theme directory using any code editor you choose.
We’ll need to remove the comments from the top of that page template and replace it with: /* Template Name: Envira Gallery Page Template */ Example Before:
Example After:
Finally, just save the file using this name single-envira.php.
Your Standalone galleries will now use your custom template automatically!
A: You can do this with CSS to hide any sidebars for that particular page template. If you need any assistance, check WPBeginner’s tutorial here.
Do I Really Need a Custom Template?
A: Not necessarily! This will depend on the theme you’re using and if your theme has provided any custom templates. You can read more about that on our How to Use the Standalone Feature in Envira Gallery.