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:
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 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?