How to create custom templates and use them with shortcodes
Included in Easy Property Listings is a template loading system that allows you to create additional templates and load them from your theme which can be used with Easy Property Listings shortcodes.
Shortcodes that can use custom templates:
- [listing] – shows a list of listings.
- [listing_category] – shows a list of listings by custom meta key and value.
- [listing_open] – shows a list of all properties that are scheduled for open inspection.
- [listing_feature] – Display listing features stored in the features taxonomy.
- [listing_location] – Display listings by location.
Setup your theme template folder
First create a directory inside your theme/child theme folder called {YOUR_THEME}/easypropertylistings/
Next copy the default loop template file from the plugin located in plugins/easy-property-listings/lib/templates/content/loop-listing-blog-default.php and place it into the easypropertylistings folder you created inside your theme.
Rename the file from loop-listing-blog-default.php to loop-listing-blog-custom.php where custom will be your new template name.
Using your custom templates
When you use a shortcode and specify your custom template that will be used to display your listings.
[listing template="custom"]
All you need to do is edit your loop-listing-blog-custom.php file as required.
Add as many custom templates as you need following the same process.
loop-listing-blog-default.php // This is the default template when using [listing] loop-listing-blog-{CUSTOM_TEMPLATE_NAME}.php loop-listing-blog-red.php loop-listing-blog-green.php loop-listing-blog-blue.php
[listing]
[listing template="{CUSTOM_TEMPLATE_NAME}"] [listing template="red"] [listing template="green"] [listing template="blue"]