Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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. –  DigitalSea Mar 25 '11 at 13:51

Your Answer

 
discard

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.