What is template overriding?
Template overriding refers to customizing a template file without making changes to the core file. Generally, when you make changes to the core file, a new plugin update overrides all of your changes. Directorist offers a robust templating system that allows you to override all the Directorist default template files without amending any of the plugin codes.
How does it work? Simply, you need to copy the template files located in wp-content →plugins→directorist→templates and paste it into your theme folder retaining the folder structure. Follow along for a detailed guideline.
How to override a template?
To override a template, navigate to wp-content →plugins→directorist→templates. Now, for example, you want to customize the Author Profile page's → "about" section which is located in wp-content →plugins→directorist→templates→author→about.php.
First, copy the file.
Then Go to wp-content→themes folder.
Navigate to your themes folder, in my case it is twentytwenty. Create a new folder, directorist then create another folder with the same name of the copied file's folder → in my case its author, since "about.php" is located in the author folder.
Paste the copied file into the newly created folder directorist → author.
So, your new theme template path would be wp content→themes→yourtheme→directorist→author→about.php.
Path of the default template file in the plugin folder | Path of the new template file in the theme folder |
/wp-content/plugins/directorist/templates/author/about.php | /wp-content/themes/yourtheme/directorist/author/about.php |
That is it! Now you can customize your new template file without changing the default files and updates will not have any effect on your customization.
*Note - Templates may update over time with new features. To avail of the new template functionalities, you need to copy the updated template file and replace the old file in your theme. So, make sure to keep a backup of your custom codes so you can add the code to the updated file.
Last Updated: April 22nd, 2021