Envira Gallery Documentation
Documentation, Reference Materials and Tutorials for Envira Gallery
Documentation, Reference Materials and Tutorials for Envira Gallery
Do you want to customize galleries created with Envira Gallery using JavaScript or PHP snippets? In this tutorial, we’ll give you multiple options to add code snippets to your site with instructions for adding your snippet. Adding custom code snippets to your site with PHP or JavaScript can extend the functionality of your site for your specific needs. Whether that be to extend your WordPress theme functionality or extend any plugin functionality.
With this guide, you’ll be able to choose which way you would like to add the snippets to your site. Once you’ve selected how to implement your code snippet, you can start exploring the developer documentation to pick and choose which snippets you’d like to start using on your site!
To have a look at the snippets available, please explore our developer documentation.
There are a handful of options for adding PHP or JavaScript to customize any part of your website from the theme to plugins or even the WordPress dashboard.
Using WPCode makes adding snippets to your site super easy!
One of the most useful features of this plugin is the built-in code check. The built-in check helps avoid any issues in your code like a missing semicolon or extra bracket then will prevent the snippet from saving. This feature helps you avoid any code errors or PHP fatal errors due to an incorrect snippet. This check is even included with the free version of WPCode!
For more details on WPCode and its features, you can check out their site documentation.
Once the plugin is installed, navigate to the Code Snippets menu from the left-hand side menu on your WordPress dashboard and select + Add Snippet.
Next, simply click the Add Your Custom Code (New Snippet), then click the blue Use Snippet button to create a new snippet.
When your new snippet screen appears, give the snippet a name that will make sense to you so you and your site admins will understand its purpose. From the Code Type dropdown, select PHP.
Next, you’ll see the Insertion section. For this particular snippet only, we’ll select Auto-Insert for the Insert Method and Frontend Only for the Location.
For this example, we’re going to create a child theme from the WordPress theme Twenty Twenty. In order to do this, please follow the steps below.
1. Create a new folder on your desktop called twentytwenty-child
2. Create a text document and these lines:
<?php
/*
Theme Name: Twenty Twenty Child
Theme URI: http://yoursite.com/twenty-twenty-child/
Description: Twenty Twenty Child Theme
Author: Your name
Author URI: http://yoursite.com
Template: twentytwenty
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwentychild
*/
3. Save this file inside your twentytwenty-child folder and name it style.css.
4. Inside this same folder, create a new doc and name it functions.php. The only thing this file will have to being is the open PHP tag: <?php
.
5. Compress or zip the twentytwenty-child folder.
6. Log into your WordPress admin and under Appearances » Themes, click the Add New to upload the twentytwenty-child.zip file you just created. When prompted, activate this theme as well.
7. Now you’ll see in your WordPress admin you’ve activated the Twenty Twenty Child theme.
Now you should have a working child theme of Twenty Twenty on your site with a blank functions.php file to add your snippets to and even a blank stylesheet where you can add custom CSS.
Your theme will still function as before, loading all the necessary files and styles first. However, any custom snippets you use from the Envira Gallery developer documentation would be added to the child theme functions.php and would customize your galleries based on the snippets you add.
And that’s just a few different ways you can easily add custom PHP or JavaScript to your site.