-2

I have created a meta field for a custom post type. This is a date field that will always be YYYY-MM-DD. There could be 100s of posts so i cant query them all and sort afterwards. I need to be able to perform a query to get 5 posts ordered by the date, for example, upcoming items. This will display 5 posts that are in the future.

I have looked into it and i can see that it is possible to provide orderby=meta_value combined with metakey=date to do this, but it doesnt treat the date as a date object. Is it possible to do this?

  • 1
    You'll need to do a meta_query, there are really plenty of info regarding this on this site. I know I have done a lot of answers on this. Have you actually checked the related posts in the sidebar of this very post – Pieter Goosen Jun 28 '16 at 12:14
0

Try to change 'orderby' => 'meta_value','meta_key' => 'event-date-start'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.