Fetching post and filtering base on date : Custom field
- By
- John Doe
- Sept 17, 2024
- 7 min read
Short Intro:
If you want to fetch a post and you want to get only the post that has a date beyond this day or the opposite, you can create a query builder like the one below
Problem:
Getting all posts beyond today's date or before today's date using QUERY BUILDER from Jetengine, listing grid and listing.
Solution:
Save the custom field as timestamp. So what is actuallly a timestamp? It is a milliseconds value of a date. We need to save it as timestamp in order to use it in a condition since date format such as "12/16/2022" is just a plain string and we can't use this to compare if it is greater or less than date that you would like to compare. This can also be used to get the post that has a date today
P.S. If there's a post that has a date custom field, I think it would be much better if we save it as timestamp so we could easily use and modify the date such as date format (by using dynamic field), conditional statements and etc.
Contact details
More solutions
by ilias
You're using JetFormBuilder and want to make sure users are at least 18 years old based on their birthday input.
by ilias
Roweij Spices wanted to have a filter that can choose number of products display per pagination
by ilias
This article will show you how to add dynamic code to your templates using the Elementor Shortcode widget and custom PHP code.
