I have a custom loop pulling out videos all assigned to various categories. However there is a category called "new-video" and I need to pull out all videos using my custom loop, but I would like the posts assigned to the category "new-video" to be shown first.

So basically the loop will treat the category "new-video" as of high priority and then show the other videos afterwards. I know you can include and exclude categories, but I don't want to exclude anything, merely prioritise.

With Wordpress 3.1 *meta_query* was introduced which allows for some pretty customisable queries, but the documentation is sparse and all of my searches thus far have returned nothing I can use.

The code I am currently using is the below if it helps:

$videos = get_posts(array(
 'post_type' => 'videos',
 'nopaging' => true,
 'each_connected' => array(
    'post_type' => 'artists',
    'nopaging'  => true,
 'suppress_filters' => false

Ignore the each_connected stuff, that is there because I am using the plugin Posts to Posts by Scribu.

1 Answer 1


Just run 2 queries, the first to pull just the new-videos and the 2nd to pull everything else but the new-videos. Probably just use WP_Query for the first one to get the new-videos and then alter the loop query for the 2nd one to exclude new-videos.

  • Genius and simple. I feel kind of stupid I didn't work this out myself, but it makes sense and I think I may have done the same thing on an older project about 6 months back. Thank you Paul. Mar 25, 2011 at 13:51

Your Answer

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

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