I'm trying to create a WP Query that displays posts from a custom post type (ca-event). In the custom post type, I'm using the date field to capture the date only.
I'd like to only display the posts that have a date that has not past (so, >= today's date). After reviewing some comments from your forums they indicated that the date field is a timestamp. However, when I do a var_dump on my date field, it outputs as a string. I've attached a screenshot from my localhost for reference.
This is my query so far.... but because the date field is outputting as a string rather than a timestamp... this is obviously not working.
Is your event date field actually a Types date field?
Because Types date fields certainly are stored as timestamps, which you can verify by checking wp_postmeta, noting that the key includes a 'wpcf-' prefix.
You have that in your query args, but where does the var_dump('event-date') in your screenshot come from? It's not a variable, obviously.
Yes, the event date field is a types date field (see attached screenshot. Sorry, correction to the var_dump. It's a var_dump(types_render_field('event-date')), after the query is run.
Just checked my database... not sure why I cannot locate wpcf-event-date anywhere. However, I have 4 posts using that custom field.... any insights on why that would be??
Ignore my previous comment about not finding the wpcf-event-date meta key in my table. I wasn't viewing all the rows in my table. It is storing the values as timestamps, not sure why the var_dump is displaying it as a string though....