I’ve created some custom fields in a custom post type using the my-meta-box-class plugin
which comes with a built in ‘date’ type of meta box input. I’m having a hard time ordering my custom posts by date. Is the date in this plugin stored as a strtotime()? If not, how can I slightly modify the plugin to get it to do so.
Is that even necessary?
Is there an easier way to order the events in my custom post type using what is already there in the plugin?
Leave a Reply
You must be logged in to post a comment.
The ‘date’ value of ‘oderby’ parameter does not sort your posts by the date specified into the metabox. It will sort the posts in context with the date when the post has been published.
If you need to sort by your date from a metabox (for custom fields) you can then use the Custom Field Parameters (http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters)
It’s not really a plugin it’s more of a library/class the plugin file there is just to show off as a demo.
any why when you call the date field you can set the format to a timestamp like this:
you can see a list of valid formats here.
and even better you can define your own validation function to store regular (literal text date) as time using php’s strtotime function like this:
and then in your addDate function call that function like this: