🔥 Black Friday: Up to 50% Off All Plans
Days
Hrs
Min
Sec

Need Help?

Here are some good places you cant start.

Whats New?

Get updated about all the good stuff!

wordpress-black-friday-deals-2025
Unlimited Elements for Elementor – Version 2.0
Unlimited Elements for Elementor – Version 2.0

Work With Query ID in Posts Selection

The Query ID lets you change the posts query of a widget with PHP code, when the settings in the widget are not enough. You give the query a unique ID, and add a WordPress filter with the same name. The filter gets the query arguments, and you can change them before the posts are loaded.

Query ID is a Pro feature. In the free version, the field is called Query ID (pro) and you can’t edit it.

Step 1: Set the Query ID

In the posts query section of the widget, for example Items Posts Query, enter a unique name in Query ID. We recommend a name with only letters, numbers and underscores, for example my_query_additions.

ue post query status order queryid

Step 2: Add the Filter

Add this code to the functions.php file of your child theme, or to a code snippets plugin. The filter name must be the same as the Query ID:

				
					/**
 * $args - the array of query arguments
 * $widgetData - the values of the widget settings
 */
function modifyMyQuery($args, $widgetData){

	// change $args here

	return $args;
}

add_filter("my_query_additions", "modifyMyQuery", 10, 2);
				
			

Example: Show Only Posts With a Featured Image

				
					function modifyMyQuery($args, $widgetData){

	if(!isset($args['meta_query']))
		$args['meta_query'] = array();

	$args['meta_query'][] = array(
		'key' => '_thumbnail_id',
		'compare' => 'EXISTS'
	);

	return $args;
}

add_filter("my_query_additions", "modifyMyQuery", 10, 2);
				
			

For more examples, including how to use a widget setting in the filter, see Current Query Posts Custom Filters.

Step 3: Check the Result

Turn on Show Query Debug in the widget. On the page, you see “applying custom args filter: my_query_additions” and the query arguments after your filter. Turn it off before you publish the page.

Where the Query ID Works

To learn about all the query settings, see Advanced Post Query.

Hurray!

You got FREE access to the worlds leading widgets for Elementor page builder!

Download is just a click away

Get instant access to tons of Elementor goodies, completely FREE!