WPCasa was built to work with any theme. But of course the basic styles and templates do not perfectly match every single theme style out there. For this reason it comes with a powerful template system for you to make it as easy as possible to overwrite default WPCasa templates with the ones you adapt for your theme.
In this tutorial we will have a look at the load process of a specific template file and go through the process of replacing a WPCasa template.
To get a better idea you may want to have a look at the
/templates sub folder that is located in the WPCasa plugin root directory. There you can see a list of templates that can be replaced by a theme, add-on or a third party plugin.
Depending on the location (e.g. in a theme) of a template file it will be considered before or after another. Let’s have a look at the load process and the order WPCasa “looks” for specific template files.
1. Child Theme
When a template is located in a child theme WPCasa would use it before any other. The template file can be located in the child theme root folder or, if you prefer, in a sub folder called
2. Parent Theme
The second most important location is a parent theme. This would be your regular WordPress theme when you don’t use a child theme. The template files can be located in the theme root folder or in a sub folder called
3. Custom Path
The third location WPCasa checks for a template in the custom path that can optionally be passed to the
wpsight_get_template() function. The third parameter of this function allows you can define a custom path.
<?php wpsight_get_template( 'listing-single.php', $args, $custom_path ); ?>
$custom_path variable could hold a path using plugin_dir_path() with your own plugin.
4. WPCasa Templates
And the last location where WPCasa “looks” for a valid template file is the
/templates sub folder of the WPCasa core plugin.
However, it is not recommended to modify the templates directly in the plugin as they will be overwritten when the plugin files are updated.
So how would we replace an existing WPCasa template?
1. Locate default template file:
Check wich template you need to modify in order to make the customization you have in mind. You find the template in the
/wp-content/plugins/wpcasa/templates sub folder of the WPCasa core plugin.
2. Copy default template content:
A good practice is to copy the content of the template file that you want to edit.
3. Create new template file:
Then create a new template file with the same name in one of the locations described above.
4. Paste default template content:
Paste the content of the default template into the new template file you just created.
5. Modify new template content:
Now customize the new template file to your special needs. Then save it and let WPCasa do the job.