epl_elementor_listing_advanced_atts: change the Listings Loop widget attributes

Description #

The Listings Loop widget is an Elementor front end for the [listing_advanced] shortcode. This filter changes the shortcode attributes the widget builds from its settings, just before the listings are queried.

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_listing_advanced_atts', 'my_function', 10, 3 );

Parameters #

$atts (array)
The [listing_advanced] attributes: post_type, status, limit, sortby, post__not_in and the other attributes the widget sets (lists joined with commas), plus one attribute per custom field filter, such as _property_bedrooms_min. EPL also sets instance_id to elementor-<widget id>, class to epl-elementor-advanced-grid and pagination to off (the widget prints its own pagination below the listings).

$settings (array)
The widget's settings.

$widget (EPL_Elementor_Listing_Advanced)
The widget. $widget->get_id() gives its Elementor ID.


Examples #

Sort by price when the widget doesn't set a sort:

function my_epl_listings_loop_sort( $atts, $settings, $widget ) {
	if ( empty( $atts['sortby'] ) ) {
		$atts['sortby'] = 'price';
	}
	return $atts;
}
add_filter( 'epl_elementor_listing_advanced_atts', 'my_epl_listings_loop_sort', 10, 3 );

Source #

lib/page-builders/elementor/widgets/archive/class-epl-elementor-listing-advanced.php, in EPL_Elementor_Listing_Advanced::build_shortcode_attributes(). Since 3.6.