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

I am using Wordpress as a CMS on a website which has standard posts, a custom advert post type and a custom event post type. The event post type has some custom meta which stores the event start date.

I am attempting to make a feed of all three post types on the home page (i.e. index.php). The standard posts and advert posts need to be ordered by their post date, but the events need to be ordered by their start date and slotted into the feed in the correct position.

Is it possible to run a query which selects all three post types and two of the post types by post date and one post type by a meta value? I'm currently using this query to bring in the standard posts and advert posts:

if (is_home() && $query->is_main_query())
    $query->set( 'post_type', array('post', 'ecs_adverts'));
share|improve this question
The first thing you should probably consider is using get_posts() or WP_Query instead of query_posts() -- see this question and its accepted answer for details. – Pat J May 14 '13 at 21:19
I don't have time to think much about this but there was what I think is a similar request from not too long ago that might prove helpful. I will check back later if I can. wordpress.stackexchange.com/a/98748/21376 – s_ha_dum May 14 '13 at 22:17
@PatJ - my bad. I realised that query_posts() was no good after my original post. I've updated the question to reflect my code changes. – ecs May 14 '13 at 22:40
@s_ha_dum - thanks for the suggestion. I didn't realise you could merge queries like that, that might just do it. – ecs May 14 '13 at 22:42

Your Answer


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

Browse other questions tagged or ask your own question.