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 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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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. – Dwayne Charrington Mar 25 '11 at 13:51

Your Answer


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.