Skip Navigation

[Resolved] Filter by Post Date for Parametric Search

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 8 replies, has 3 voices.

Last updated by jasonH-4 9 years, 7 months ago.

Assisted by: Caridad.

Author
Posts
#238421

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!

#238459

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ł

#238975

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!

#239107

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

#239333

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

#239419

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

#239648

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

#239649

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.

#240061

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!

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.