0

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'));
4
  • 1
    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, 2013 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, 2013 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.
    – edcs
    May 14, 2013 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.
    – edcs
    May 14, 2013 at 22:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.