I set up a bunch of Custom Search Filter in my WP Archive to filter through the posts, including a generic search and some taxonomy filters. I would also like to add a date filter. I read the forums and I'm a bit confused, because I see two solution types:
- make a new custom field with dates
- do a fair amount of whizz code magic
I'm a bit puzzled, as both options seem like more work than I expected this to be. My posts all already have dates on them, is it really necessary to duplicate them in a new custom field? Is it really not possible to just use the existing Post Date attribute easily?
Hello, there are two different types of date filters in Views. One is based on the date the post was published or last modified, the other is based on a custom date field. The main difference between the two data sources is that the custom date field can hold any arbitrary date, not tied to the date when the post was published or the last date the post was edited. The two types of filters offer different built-in filtering options, and sometimes custom code is required for either type depending on the exact type of filtering you want to achieve. Here are two documents that give an overview of post date filters and custom date field filters:
Post Date filters:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-date/
Custom date field filters:
https://toolset.com/documentation/user-guides/views/date-filters/
If you explain in some detail the filter you would like to implement, I can give you more guidance for selecting the correct filter type and configurations. Let me know if you need additional help with that.
I'm trying to figure that out, but the only query filter I can find in the WP archive is in the sidebar and it seems to work to filter the loop results from the admin side.
That's not what I'm trying to do. I want a filter which will allow the users to filter by date. As in, I want all posts displayed, and I want the users to be able to select a date range and the archive to then display posts from within that range.
I managed to do something similar for categories and custom taxonomies by creating custom search filters in the archive. Now users can select a category and filter loop results. I want them to be able to do the same by date. But the 'Insert Custom Search Filter' dropdown just doesn't list 'Post Date' as an option. I can filter by taxonomies, by Post Relationship, by Map Distance, or do a Text Search. There just is not option to filter by date there.
Also, I'm a bit confused by the fact that you keep referring to Views - I thought Views were retired? When I try to activate the plugin, I just get a message: Toolset Blocks is a different flavour of Toolset Views. You can not use both versions at the same time, so we have deactivated one.
Am I doing something wrong?
I want the users to be able to select a date range and the archive to then display posts from within that range.
Post publication date filters are all managed in wp-admin, and predefined. That's not what you want. You want a front-end, custom search filter that allows Users to select a date range. This kind of filter is only possible for filtering by custom fields, it is not possible for filtering by post publication date in the current system. You must add a custom date field to the post and manage the date here instead of the post publication date if you want to allow front-end filtering by your site visitors.
Also, I'm a bit confused by the fact that you keep referring to Views
"Views" can refer to two things: Views the plugin and Views the filterable lists of posts. Before Blocks, you used Views (the plugin) to create Views (the lists). Now you can use either Views (the plugin) or Blocks (the plugin) to create Views (the lists). In Blocks, you will drag a View block into the editor to create a new View or use a View that was created elsewhere on the site. It's still called "a View" even though the Views plugin is no longer involved.
Thanks! I think it's odd, but at least I know what to do. The only problem is - I now have over 250 posts to add a new field to. Do you know of any automated way which would allow me to copy the Year value from each Post Date to the new field in each post?
Toolset's date field does not support just a year value because it requires a Unix timestamp format. You would have to provide a specific date in Unix timestamp format for each post. A simple number field would be better suited for storing just a year value, and you can use a "between" comparison to create a min-max range filter for querying that number field. Beyond that, there are some 3rd-party plugins that claim to allow bulk editing of custom field values, but none of them are specifically integrated with Toolset so I can't speak to their effectiveness. For a simple numeric field, I think they would likely work better than for a date field, which requires the Unix timestamp format.
My issue is resolved now. Thank you!