I am adding a new “Custom Post Type” named “Seminar”. I am defining three custom fields
- Location
- StartTime
- EndTime
StartTime and EndTime are going to store dates (surprise, surprise). I am wondering if there’s any way to tell WordPress to treat these like dates so that I can sort by them and stuff.
I am very new to WP, so forgive me if this is a dumb question.
Hia.
Basically no. But, you can order by meta_value in WP_Query, so you can sort. I am not sure what format you are storing the dates as, but it will need to be something that MySQL can order by, a simple Unix timestamp would be fine, you would do:
Would get all the seminars with a start date after “now”
The custom field value is stored as is – and I think you can use Joe’s answer to get the posts, however to “sort” using start time you might need to use something like this:
There is a plug-in called more fields, that I think will let you do this without writing code. You can add a new input box only to your custom post type, then select date under advanced options.