epl_property_blog_template: choose the listing card template file
Description #
Changes which template file EPL loads for each listing in a list of listings: archive pages, search results and the listing shortcodes. EPL picks loop-listing-blog-{template}.php, where {template} is default or the template a shortcode asked for, such as card, slim or table.
Use it to load a different file for some listings, for example a different card for rentals. EPL looks for the file in your theme first (in easypropertylistings/), then in EPL. If it can't find the file it uses loop-listing-blog-default.php.
It doesn't run when a function is hooked on epl_loop_template, epl_loop_template_listing or epl_loop_template_{post_type}; those replace the template altogether.
Usage #
add_filter( 'epl_property_blog_template', 'my_property_blog_template', 10, 2 );
Parameters #
$tpl_name (string)
The template file name, for example loop-listing-blog-default.php.
$vars (array)
The variables of epl_property_blog() at that point. Useful ones: $vars['property'] (the EPL_Property_Meta object for the listing), $vars['template'] (the template name asked for, such as card) and $vars['property_status'].
Examples #
Show rentals with the slim template:
function my_property_blog_template( $tpl_name, $vars ) {
if ( 'rental' === $vars['property']->post->post_type ) {
return 'loop-listing-blog-slim.php';
}
return $tpl_name;
}
add_filter( 'epl_property_blog_template', 'my_property_blog_template', 10, 2 );
Related #
- Add custom class to listing wrapper on archive pages and shortcode
- [listing] Shortcode: the
templateoption.
Source #
lib/includes/template-functions.php, in epl_property_blog() (since 3.3), and since 3.6 in lib/page-builders/elementor/class-epl-elementor-template-router.php, in EPL_Elementor_Template_Router::render_php_fallback() (Elementor listing cards fall back to the PHP template).