I have created a custom post type called 'events'. On the index page, I want to amend the loop to list all posts (standard and events). However, I want to order standard posts by the date it was posted, and I want to order events by a custom field which contains the date of the event.
Example:
Standard Post (Posted on 12th May 2014)
Standard Post (Posted on 11th May 2014)
Event Post (10th May 2014)
Standard Post (Posted on 9th May 2014)
Event Post (8th May 2014)
Event Post (7th May 2014)
Standard Post (Posted on 6th May 2014)
I have added these parameters for query_post on the index.php
<?php
query_posts( array(
'post_type' => array( 'events', 'post'),
'meta_key' => 'date_of_event',
'orderby' => 'meta_value',
'order' => 'asc',
'meta_query' => array(
'key' => 'date_of_event',
'value' => date("Ymd"),
'compare' => '>=',
'type' => 'DATE'
)
)
);
?>
At the moment I only have events being returned