epl_elementor_listings_query_args: change the EPL Listings widget query
Description #
Filters the WP_Query arguments the EPL Listings widget builds when its Source is Custom Query. Use it to add conditions the widget's controls don't offer.
The EPL Listings widget is only available when Elementor's Loop Grid isn't (see epl_elementor_has_loop_grid). With Source set to Current Archive Query the widget shows the page's own query and this filter doesn't run.
Part of the Elementor integration, which is in beta. See Elementor widgets and templates (beta) for how the widgets and templates fit together.
Usage #
add_filter( 'epl_elementor_listings_query_args', 'my_function', 10, 2 );
Parameters #
$args (array)
WP_Query arguments: post_type, posts_per_page, paged, order, orderby, meta_query (listing status), and meta_key when sorting by price.
$settings (array)
The widget's settings, for example $settings['post_type'], $settings['status'] and $settings['limit'].
Examples #
Only show featured listings:
function my_epl_listings_featured( $args, $settings ) {
$args['meta_query'][] = array(
'key' => 'property_featured',
'value' => 'yes',
);
return $args;
}
add_filter( 'epl_elementor_listings_query_args', 'my_epl_listings_featured', 10, 2 );
Source #
lib/page-builders/elementor/widgets/archive/class-epl-elementor-listings.php, in EPL_Elementor_Listings::get_listings_query(). Since 3.6.