I got posts that have starting date as a custom field value. I'm displaying few of those posts in my sidebar in ascending order so that the post with closest starting date is shown first. This is what I have and it works great:

1 Answer
1

For this to work reliably, the date format in the database should be yyyy-mm-dd. Comparison type should be DATE or NUMERIC. If you take the date of 25-04-2012 in present format and compare it numerically to the date 26-04-1986, you can see what the issue will be: 25042012 < 26041986

ALso- if you're doing these queries in addition to your main loop, use a new instance of WP_Query.

EDIT-

there were a few errors you didn't fix. note that this still won't work quite right until you fix the date format.

Thank you for the suggestions, great points in using date or numeric instead of >. However, no matter if I use WP-Query or not, I can't get the posts to display. No errors or anything, the sidebar is just empty. Something wrong with my query?
–
AndrewApr 25 '12 at 14:55