Skip Navigation

[Resolved] default_label is not working with the [wpv-control] shortcode (select fields)

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 1 voice.

Last updated by Paul Marconi 1 week, 2 days ago.

Assisted by: Minesh.

Author
Posts
#2817969
post-date-filter.jpg

Hi there,

We are using the toolset Views plugin (legacy version) to create a News View with filters.
There are 2 filter fields: Filter by Category + Filter by post published year
Both filters are using a select dropdown field.

The Filter by Category is working fine because this is using a custom taxonomy, but the filter by year is partially working.
I am not able to set the default label.

For the Filter by post published year select field, I've used 'Post Date filter' under the query filter section.
In the 'date condition', I've set it to: (screenshot attached).
============================================
Select posts with 'published date' 'in any of those'
Year
URL parameter > wpv-year
=========================================

In the 'Search and Pagination' section, to display the published years in a select dropdown field, I've used:

[wpv-control type="select" order="DESC" values="2025,2024" url_param="wpv-year" default_label="Year" default_value="2024"]

In the front-end, the select dropdown shows the years that I have added in 'values', but it didn't add in the default label option, which is 'Year', and the default value is not set to '2024'. I thought using 'default_label' + 'default_value' does that, but it's not working.

How can I set the default label + default value for the Year select field (using the 'Post Date filter' + [wpv-control] )?

thank you!

#2818036

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You should try to use the following shortcode to display your select filter:

[wpv-control field="post_date"  source="custom"  type="select"  display_values="Year,2025,2024" values="'',2025,2024" url_param="wpv-year"]

There is no attribute for default value, so you will have to set the default option using the custom Javascript/jQuery. For example:

jQuery(document).ready(function($) {
  $('select[name="wpv-year[]"]').val('2024').trigger('change');
});
#2818091

Thank you Minesh! Your code works!
If we want to changed the order of the year to be ASC or DESC, I tried adding order="DESC" to the [wpv-control] shortcode, but it does not work:
`
[wpv-control field="post_date" source="custom" type="select" display_values="Year,2025,2024" values="'',2025,2024" url_param="wpv-year" order="DESC" ]
`

So do we need to update it manually in the 'display_values' + 'values' parameters?

thanks!

#2818217

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You need to manage the order with the 'display_values' + 'values' parameters manually.

#2818266

Thank you Minesh!