Skip Navigation

[Resolved] Ajax search filter does not have defaults applied

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by MrHinsh 1 year, 4 months ago.

Assigned support staff: Waqar.


I am trying to: Have a default date filter applied, which is shown. However The first load of the form does not honor the default filters.

Link to a page where the issue can be seen: hidden link

I expected to see: I do not expect to see listings with a date older than today.

Instead, I got: Items prior to the date selected listed.


I created a partial fix by adding:

jQuery(document).ready(function($) {
jQuery("select[name^='wpv-wpcf-training-scope'] option[value='Public']").attr("selected","selected").trigger("change");

However this code also runs when the page is refreshed which is incorrect. I only want it to run when the seach has not been run...



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)


Thank you for contacting us and I'd be happy to assist.

To suggest the best way to achieve this, I'll need to see exactly how this view's search filters are set up in the admin area.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.




Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)


Thank you for sharing the access details.

The "Course Schedule" page on your development website seems to be set up differently than the one at the staging website for which you shared access details.

However, if your goal is to apply the event date filter by default, to show only events starting from today, you can remove that custom script and instead use "wpv_filter_query" hook:
( ref: )

add_filter( 'wpv_filter_query', 'default_date_filter_fn', 1000 , 3 );
function default_date_filter_fn( $query_args, $view_settings ) {
	if ( !is_admin() && ( isset($view_settings['view_id']) && $view_settings['view_id'] == 1234) ) {
			$date = new DateTime(date('l jS F Y'));

			$query_args['meta_query'][0]['key'] = 'wpcf-event-date';
			$query_args['meta_query'][0]['value'] = $date->getTimestamp();
			$query_args['meta_query'][0]['type'] = 'NUMERIC';
			$query_args['meta_query'][0]['compare'] = '>=';
			$query_args['meta_query']['relation'] = 'AND';
	return $query_args;

Note: Please replace '1234' with your actual View's ID.

The above code snippet can be included through either Toolset's custom code feature ( ref: ) or through active theme's "functions.php" file.

I hope this helps and please let me know if you need any further assistance around this.



This was awesome and sorted it right out! Perfecto.