fbpx

Need Help?

Here are some good places you cant start.

Whats New?

Get updated about all the good stuff!

February Updates
Currency Converter Cover
Layers Widget

Current Query Posts Custom Filters

Current Query Posts – This type works only when the widget is inside of an archive template. It shows the current posts which are being used in the archive page.

To create custom filters not available in the settings using php code. You can assign the post list a Query ID (this feature is only available in the the pro version of unlimited elements)
Using the Query ID feature you have unlimited possibilities to select your posts.

Instructions how to use the query ID filter: 

In the widget you set the query ID to my_query_filter

After that you go to your theme folder – functions.php file and add those lines:

				
					/*
 * filter the arguments to get my custom posts
 * args - original arguments
 * $widgetControlsValues - all the values of the current widget. 
 * it can be used for the post list
 */
function myQueryFilter($args, $widgetControlsValues){
	
	//set filter to posts that published within 24 hours (today)
	$args['date_query'] = array(
	        'column'  => 'post_date',
	        'after'   => '-1 days'
	 );
					
	return($args);
}

add_filter("my_query_filter", "myQueryFilter", 10, 2);
				
			

Another code example, with use of $widgetControlValues. For this example you create a dropdown attribute with those settings: 

Name: day, values: all, today, tomorrow. What we want is that if today chosen, it will filter posts only from today, and if yesterday chosen, it will filter posts from yesterday. So in functions.php you insert this code: 

				
					/**
 * filter the arguments to get my custom posts
 * args - original arguments
 * $widgetControlsValues - all the values of the current widget. 
 * it can be used for the post list
 */
function myQueryFilter($args, $widgetControlsValues){
		
	$day = $widgetControlsValues["day"];
	
	if($day == "today"){
		$args['date_query'] = array(
	        'column'  => 'post_date',
	        'after'   => '-1 days'
	    );				
	    
	}
	else
	if($day == "yesterday"){
		
		$args['date_query'] = array(
	        'column'  => 'post_date',
	        'after'   => '-2 days',
		'before'  => '-1 days'
	    );		
	}
	
	
	return($args);
}
add_filter("my_query_filter", "myQueryFilter", 10, 2);

				
			

Of course, you don’t have to put your code into functions.php, there are certain plugins that you can put php code snippets into without updating theme php files. 

Download is just a click away

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

Hurray!

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