Order by meta fields in Wordpress

I may have made a poor decision but I have some custom fields in Wordpress that allow users to input numbers for a month, day and year. I wanted this separate from the publish date fields in WP because I felt this would be easier and because the client has lots of older content they need to publish.

So how can I query and order by meta fields or what is the best way to do this? order by the day, month and year fields, all of which contain numbers.

Thanks in advance.

I would tell them to use the publish field, and type in the [old] dates by hand. If you have 5 posts and they were dated in the last week, withe the newest at #1. Publishing it with a date of Dec 23, 2011, will put it at #6 not #1.

So is that generally the best way to go about it? Part of the reason I set it up this way was because sometimes articles are published that have different dates from when the WP post is published so I created these fields to differentiate.

You can make the WP publish date anything from either 1-1-1900 or 1970 to 12-31-9999, this is a MySQL limitation. @r937 would know the answer.

Are you bringing the old content in to have it all there (like archiving) or do you want to push the content as new and just be able to say give me stuff originally written in 2005?

sorry, no idea, i don’t do wordpress

Rudy, my throw to you was the date ranges in MySQL.

date ranges depend on which datatype is being used to store the date, and as i said, i don’t know wordpress, so i don’t know which of the 4 different ways of storing dates applies here

da manual is the best reference for datatypes

:slight_smile:

Oh ok, I didn’t realise that there were 4.

The datatype is a text field for month, day and year. I assumed there could be a way to read those as numbers and have some formula to be able to organize it appropriately.

Rpeg, can you answer the question I asked in #4?