From what I've read on the Forum this is not possible to do using Views. Is there any chance that this will be added to Views in the future?
Also, i understand how to create a custom field with a date and add it to each post, and then filter it using the custom field date. But is it possible to use the parametric filter on the custom field date?
I basically want to filter my view by the year. Have the user be able to filter the posts to show things by the year (2014, 2013, etc.). Any advice on how to do this is appreciated.
Thanks!
Dear Jason,
You are right, there is currently no way to filter by post date.
You can instead add a numeric year field to all posts and then filter by that field.
To automate this process for new posts, you can add a save_post action hook and let WordPress automatically populate the fields when saving the post. Please read http://codex.wordpress.org/Plugin_API/Action_Reference/save_post to learn more about this.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Paweł
I have created a custom field that is a date for every post - what I don't understand is how to set it up so the user can filter it on the front end. Ideally what I'd like to do is have the user pick a start date and end date and see all the posts within that timeframe. Is that possible using my custom date field? If so, can you give me some advice how to set it up?
Thank you!
Dear Jason,
You need to setup a date filter using the BETWEEN operator:
https://toolset.com/documentation/user-guides/date-filters/
Then you can add the corresponding parametric search controls in the “Filter HTML?? section.
https://toolset.com/documentation/user-guides/front-page-filters/
Please let me know if you are satisfied with my reply and any other questions you may have.
Regards,
Caridad
Hi Caridad, I understand the first part, how to set up a view using a date filter. I have no problem setting up a view that filters between a set of dates I set up. What I don't really get is how to use the filter html section for the front-end user to filter dates.
If I set something up along the lines of:
[wpv-filter-controls]
[wpml-string context="wpv-views"]Start Date:[/wpml-string]
[wpv-control field="blog-date" url_param="blog-date_min" type="date"]
[wpml-string context="wpv-views"]End Date:[/wpml-string]
[wpv-control field="blog-date" url_param="blog-date_max" type="date"]
[wpv-filter-submit name="Submit"]
[/wpv-filter-controls]
It shows little calendars on the page with the view, but if I change the dates in those views and click on submit, it takes me to the most recent post (outside of the dates I submitted).
Maybe you can give me an example or two of the filter html section for filtering a custom date field. I think if I see some samples I will get it.
Thanks,
Jason
Dear Jason,
From your comments, I think you are doing this correctly. This is starting to sound like an bug we recently fixed. Can you confirm that you have all Toolset plugins updated?
Regards,
Caridad
Hi Caridad,
I was indeed still using older versions of Types and Views. Updated to the newest version but it's still not working. Same problems as before. I'm sure I am doing something wrong but cannot figure out what it is.
Thanks,
Jason
If I turn on the "Update the View results every time an input changes" and then select a blog_date_min of some time in 2012, it says no items found (even though the range at this point should be from 2012 to now). I'm obviously doing something wrong.
You were right, Caridad. I was on the right track. Some other code that had nothing to do with Types and Views was messing things up. All is good and it is working. Thanks so much!