WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a page, I want to display content from four areas, posts and three custom post types, and sort them all by date. The post date is post_date and the cpt dates are meta_value values called, for example, cpt_date1, cpt_date2, and cpt_date3 (containing strings in unix date format).

How do I write arguments for WP_Query to accomplish this?

Any help is appreciated!

share|improve this question
If you are using a custom post type, which is really just a variation on the default post type, why not just use the post_date value for the custom post type as well? It should be the same as the default post type, unless I've missed something about why you would want to declare it as meta value. – Brent Sep 14 '12 at 5:58
Probably because he has multiple date fields and wants to sort on them all. At least that's how I interpreted the question. The meta value dates are probably set by the editor as dates for events or something like that. – hampusn Sep 14 '12 at 7:12
Brent, I agree and may be able to do that. But if not, I just wanted to understand my options. These answers are great. – therobbiedshow Sep 14 '12 at 16:09

You can actually use two filters to accomplish this.

Use posts_join for the joining of the meta table (unless you know it's already included in your wp_query. And posts_orderby for the sorting.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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