Home › Forums › Front-end Issues › Displaying posts using a custom date field › Reply To: Displaying posts using a custom date field
1- it should be just start_date
. That is the meta key which is the same as the field name.
2 – You should change the check to check for your post type that way the query is only changed for your post type.
if (isset($query->query_vars['post_type']) &&
$query->query_vars['post_type'] == 'your-post-type-here') {
3- You must be using ACF4. ACF 5 has a Display Format
and Return Format
and always stores all dates as YYYYMMDD. You will need to alter your save format to something that is recognized as a date by WP. Either that or you’ll need to set the meta type to CHAR
or NUMBER
I think.
When posting code you should put it inside back ticks, or use the code button at the top of the reply box, makes it a lot easier to read.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.