Skip Navigation

[Resolved] Preset value of Taxonomy filter dropdown

This thread is resolved. Here is a description of the problem and solution.

Problem:

Is there some event I need to trigger to get Views to update the displayed results?

Solution:

You can try to modify your JS codes as below:

https://toolset.com/forums/topic/preset-value-of-taxonomy-filter-dropdown/#post-1367151

Relevant Documentation:

https://api.jquery.com/trigger/

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by davidS-53 5 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1367007

I have a wordpress archive set up with a taxonomy filter select dropdown named "wpv-product-category". When navigating to the page, I want to preset the taxonomy select option to "household". I have the following JQuery added to the JS of the filter section:

jQuery(document).ready(function($) {
jQuery("select[name^='wpv-product-category'] option[value='household']").attr("selected","selected");
});

It changes the select value just fine, but does not update the results on the page. Is there some event I need to trigger to get Views to update the displayed results?

Thanks for your help.

#1367151

Hello,

I assume you are using AJAX search option: AJAX results update when visitors change any filter values
You can try to modify your JS codes as below:

jQuery(document).ready(function($) {
	jQuery("select[name^='wpv-product-category']").val("household");
	jQuery("select[name^='wpv-product-category']").trigger("change");;
});

More help:
hidden link

#1368237

Works a treat, thanks a lot!