Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.