Skip Navigation

[Resolved] Need to do a date search by month

This support ticket is created 4 years, 1 month 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 9 replies, has 2 voices.

Last updated by Minesh 4 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1545979

Tell us what you are trying to do? I'd like to search the date field by month. So, for instance, finding all the dates that are in March 2020

Is there any documentation that you are following? I am trying to figure out if this would work: https://toolset.com/forums/topic/date-filter-not-working/ - Would the function code go in my functions.php file?

Is there a similar example that we can see? Not that I can find. Basically, each class has a specific start date. I want to be able to filter by month to show all classes that start in March 2020 or April 2020, etc.

What is the link to your site? hidden link

#1546671

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to have more information here.

- Do you want to display both March and April classes or class posts belongs to single month of March?
- How the start date is added - is it added using the Types custom date field?

#1551111

I would just need to display one month at a time. I guess they would have to choose month and year from upcoming entries.

Yes, the date is a Types custom date field.

#1551113

It could probably be a dropdown with the current and upcoming months.

March 2020
April 2020
May 2020
July 2020 (there might not be any June entries)
September 2020

Etc, etc.

#1552193

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You need to add the custom field frontend filter using the custom values.

Can you please share problem URL and access details so I can setup the filter on your view and share the details with you about the resolution.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1554633

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check: hidden link

I've added the following filter to your view's Search and Pagination section:

[wpml-string context="wpv-views"]Month:[/wpml-string] [wpv-control url_param="wpv-month" type="select" values=",1,2,3,4,5,6,7,8,9,10,11,12" display_values="All,January,February,March,April,May,June,July,August,September,October,November,December"]

As you can see I've added months from Jan-Dec.

This way you can select the month and it will filter the results, If you agree, I will proceed to add the filter code.

In addition to that, I need to check against class start date and class end date and if both falls under the selected month only those posts should be displayed, correct?

#1556577

So that's not really what I meant. I need it to show only the actual upcoming options. Can it not fetch the dates of upcoming classes and put the options like this?

March 2020
April 2020

I don't want it to show options that aren't available.

#1557179

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As I inform you in my previous reply that there is no native feature available to add month filter but as I said I can share workaround and that is why before I implement it I wanted to show you how it will look like.

As there is no such feature available, I see you only wants to add months to the dropdown which are currently available, its possible but require too much custom code which is beyond the scope of our support policy.

However - I suggest you should file a feature request and raise your voice in front of our product manager to add month dropdown for the date type fields filters using the following link:
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

If you want, we can go with the workaround I shared, you may need to compromise with your requirement as it will not work how exactly you want or maybe you can add a custom taxonomy for months and month names as terms and add taxonomy filter and attach the month term with your posts while create/edit your posts.

#1557559

I guess is that's my only option, then let's do it this way. I see the dropdown you created and see that it isn't functional yet. What do we need to do to make it work?

I made some visual changes to what you put in there. If we could just get that month dropdown working, that would be great.

I truly appreciate your help.

#1561489

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - so HOw you want the filter should work.

You want to display all the classes:
- want to display posts having Class start date and end date both fall in a selected month?
- want to display posts having class start date falls in a selected month?

Because something class date start in January and ends ins February month. Please let me know how you want to display the posts and accordingly I will try to share workaround.

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