1. Template files
To view all template files of a VillaTheme plugin, navigate to wp-content/plugins/{slug_of_plugin_you_want_to_override}/templates/
In the documentation, we also list all of our plugins’ template files. Please visit https://docs.villatheme.com/, choose the plugin you want to check, and scroll down to or click the DEVELOPERS menu (if any).
2. Override a template step by step
Step 1: Create a directory within the root directory of the currently active theme and name it {slug_of_plugin_you_want_to_override}(skip if the directory already exists)
Step 2: For each subdirectory of the original template file after /templates/, create a new directory with the same name.
Step 3: Copy the original template file to the final directory created above so that the file structure of the new file is the same as the original file with or without /templates/, you should try both because it’s different for different plugins. For example, to override templates of WooCommerce Boost Sales plugin, the file structure of new template file must be without /templates/ while to override WooCommerce Photo Reviews plugin, the file structure of new template file must contain /templates/
-> Now you can edit the new file to override the default template without changing the core template files hence changes will remain when the plugin is updated.
Note 1: Overriding templates of VillaTheme plugins via a theme is different from the premium and free version by the slug name. Please be mindful of the directory name when overriding templates via theme in the premium and free version. The examples below show how to override the templates of the two plugins using a theme for the premium versions and free versions
3. Examples for the premium version
- Example 1: Override the /single-product/add-to-cart/add-to-cart.php template of WooCommerce Boost Sales plugin
Step 1: Create a directory within the root directory of the currently active theme (Storefront- for example) and name it: woocommerce-boost-sales
Step 2: With WooCommerce Boost Sales plugin, you can see 2 sub directories of the original template file after /templates/ are admin and single-product. The/single-product/add-to-cart/add-to-cart.php template is located in the Single-product > add-to-cart
So you will create new directory with the same name single-product and new sub-directory add-to-cart in the the original template file.
Step 3: Copy the single-product/add-to-cart/add-to-cart.php template to the final directory created above so that the file structure of the new file is the same as the original file without /templates/ like this: …/wp-content/themes/storefront/woocommerce-boost-sales/single-product/add-to-cart
- Example 2: Override the /viwcpr-template-masonry-html.php template of WooCommerce Photo Reviews plugin
Step 1: Create a directory within the root directory of currently active theme (Storefront- for example) and name it: woocommerce-photo-reviews
Step 2: With WooCommerce Photo Reviews plugin, there is no sub-directory, and the /viwcpr-template-masonry-html.php template is located in this original template file.
Step 3: Because WooCommerce Photo Reviews need to create a template directory inside, so create a template directory inside the woocommerce-photo-reviews directory.
Copy the /viwcpr-template-masonry-html.php template to the template directory that you created above so that the file structure of the new file is the same as the original file like this: ../wp-content/themes/storefront/woocommerce-photo-reviews/templates
4. Example for the free version
Override the /single-product/add-to-cart/add-to-cart.php template of Woo Boost Sales plugin
Step 1: Create a directory within the root directory of currently active theme (Storefront- for example) and name it: woo-boost-sales
Step 2: With Woo Boost Sales plugin, you can see 2 sub directories of the original template file after /templates/ are admin and single-product. The/single-product/add-to-cart/add-to-cart.php template is located in the Single-product > add-to-cart
So you will create new directory with the same name single-product and new sub-directory add-to-cart in the the original template file.
Step 3: Copy the single-product/add-to-cart/add-to-cart.php template to the final directory created above so that the file structure of the new file is the same as the original file without /templates/ like this: …/wp-content/themes/storefront/woo-boost-sales/single-product/add-to-cart
Note 2: For the new template file to not be lost when you update your theme, please use a child theme instead. If you do not have a child theme yet, please follow this guide to create one.