Skip Navigation

[Resolved] Allow users to filter results by month from a custom date field

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

This topic contains 3 replies, has 2 voices.

Last updated by hannahM 6 years, 10 months ago.

Assisted by: José Arcos.

Author
Posts
#623204

I've created a custom post type using Toolset; one of the fields is a date field which can have multiple values (the post type is Training Courses and each course will run a number of times)

I'm building a View for this post type, and I want to allow users to search courses using this custom date field. Currently I have a start and end date which users can select: hidden link

What I'd ideally like to do is to have a drop-down where they select the month, and they can see any courses which contain a date within that month. Is it possible to do something like this using Toolset? I couldn't see anything in the documentation.

I found this support query which shows how to filter dates within a specific month: https://toolset.com/forums/topic/filter-results-by-a-specific-future-month-using-custom-date-field/ - but this is a back-end filter whereas I'd like something on the front-end.

No worries if this isn't possible, I just thought I'd ask!

Many thanks

Hannah

#623374
functions php screenshot.png
views pane screenshot.png
query filter.png

Hi there,

As an update to this, I found this solution in another support thread: https://toolset.com/forums/topic/date-range-between-fixed-month-links/

I have been able to get it to work using the first non-Ajax method, but I'm unable to get the Ajax method working using the method described; trying to do that has seemingly prevented any of the filters from working: hidden link
(see attached screenshots which show I have implemented the method as described)

The form on this website doesn't have to be Ajax, but the original non-Ajax method had its own submit button for the monthly dropdown, whereas I have a number of fields which all need to be controlled by a single submit button.

I am hoping you might be able to discuss this with / assign this to Noman and either see if you can work out why the Ajax method isn't working, or let me know a method which would allow the monthly dropdown to use the submit button for the entire filter section?

Many thanks

Hannah

#623382

Hello Hannah, thank you for contact us. I will try to do my best to help you.

This is possible but you will need to write some custom code and some modifications to your template. First, you need to add a custom dropdown, adding month names as drop-down options. Then, you need to build a custom shortcode where you should convert the date field into a month and compare with selected month, if it matches, then, display the post, otherwise not.

There is an existing solution already written by one of our supporters in this thread: https://toolset.com/forums/topic/filter-by-month-and-day/#post-336365

Please let me know if this solves the issue or if you need further details.

Have a good day.

#623391

Hi Jose,

Thanks very much for your response. I'm not quite sure what happened but it appears the Ajax method is now working correctly! It might have been a caching issue on my end, but the filters now appear to be working properly 🙂

Thanks for your offer of help, and if someone could please pass on my thanks to Noman for his solution in this thread: https://toolset.com/forums/topic/date-range-between-fixed-month-links/ which I was able to repurpose, I'd be very grateful.

Thanks!

Hannah