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 am migrating a static magazine site to wordpress. I would like to have a frontpage displaying multiple categories with a few posts in each, e.g "politics", "environment", "health" and "technology". On top of that I would like to have a "latest news" category. The posts displayed in the "latest news" category will also belong to another category (and child category e.g poltics-->asia-->india) and show up on a page with posts only from the specific category (e.g a "politics" page), but they cannot be duplicate posts on the frontpage as long as they show in the "latest news" category. The categories would be displayed in a grid magazine type design. An example of what I am trying to accomplish is this site, a well-known pirate party blog.

Can someone point me in the right direction how I would accomplish this? Basically I would need to be able to have maybe ten loops in the same page, without any duplicate posts. Very grateful for any help.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I wrote a class specifically for passing data between widgets classes using static variables and it will work for your use case as well. Grab the class here.

The way you would use this is as follows for each custom loop:

$exclude_ids  = IntermediaryData::get(); //Retrieve previous exclude IDs
$args['post__not_in'] = $exclude_ids;

//new WP_Query($args); Custom loop query

//Loop Start
     $exlude_ids[] = $post->ID,
//Loop End

IntermediaryData::set($exclude_ids); //Pass IDs to next loop
share|improve this answer
    
Thank you very much Brian. I will have a look at your suggestion. I have found a working solution at: wprecipes.com/… –  sarytash Feb 5 '12 at 2:39

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.