Skip Navigation

[Resolved] Archive Query filter based on CRED expiration time field

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to filter a WP Archive using the post expiration timestamp from Forms, i.e. the _cred_post_expiration_time field.

Solution: Use the archive's Query Filter editor to add a query filter based on that hidden custom field value. First, you must expose the hidden _cred_post_expiration_time field to Views filters. Go to Toolset > Settings > Front-end Content, and add _cred_post_expiration_time in the "Hidden custom fields" section. Then in the WordPress Archive, add a Query Filter based on the _cred_post_expiration_time custom field. Configure the filter so that it finds results with _cred_post_expiration_time greater than or equal to NOW, or TODAY, as shown in the screenshot here. You may have better results with TODAY depending on your server's timezone settings, but you can try NOW or TODAY in the filter configurations to see which one gives the best results.

This support ticket is created 3 years, 6 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 3 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#2039243

Hello,
I have a CPT "Inzeraty" (classifieds) with custom post type Archive.
Using CRED form each single classified has its own expiration date set by $(_cred_post_expiration_time) field.
I need to query filter the post type archive to show classifieds with expiration date equal or greater than the date set via the $(_cred_post_expiration_time) field.
Did not find any documentation or similar problem in Support forum.
Could you help, please?
Thanks,
Tom

#2039869
Screen Shot 2021-05-02 at 11.42.23 AM.png

I need to query filter the post type archive to show classifieds with expiration date equal or greater than the date set via the $(_cred_post_expiration_time) field.
I assume you mean you want to display classified posts with expiration date equal or greater than the current date, based on the expiration in the _cred_post_expiration_time field, is that correct? In other words, posts that have not yet expired?

If that is the case, you can use the archive's Query Filter editor to add a query filter based on that hidden custom field value. First, you must expose the hidden _cred_post_expiration_time field to Views filters. Go to Toolset > Settings > Front-end Content, and add _cred_post_expiration_time in the "Hidden custom fields" section. Then in the WordPress Archive, add a Query Filter based on the _cred_post_expiration_time custom field. Configure the filter so that it finds results with _cred_post_expiration_time greater than or equal to NOW, or TODAY, as shown in the screenshot here. You may have better results with TODAY depending on your server's timezone settings, but you can try NOW or TODAY in the filter configurations to see which one gives the best results.

Let me know if this will not work for your needs, and I can give you some additional feedback.

#2039905

Whooooooooooaaaaaa!
Christian, thank you! I have spent several hours trying to get the value of the _cred_post_expiration_time field into Toolset so that I could use it the same way you suggested. That step with Hidden fields is a pure magic 🙂
Thank you VERY much! It works like a charm 🙂

#2039953

Excellent, glad to help.