Michael as far as I can tell, The Loop article (which I had already consulted before posting here) does not tell me how to do what I asked in this thread. If I’m mistaken, please direct me to the example in the article where it does.
I need a loop that will only disply posts from one particular category.
If possible, I’d like it to be able to be a multi-part type thing so I can do things like display the entire contents of the first post in that category, and only the excerpts in the following posts.
Maybe it would help if I showed the code I’m already using to accomplish most of what I want, which is the entire contents of a post from a particular category in one column, possibly followed by excerpts from the next few posts in that category. In the other column, there are excerpts from all the posts excluding the one category presented in the first column.
So far, I have the second column behaving exactly as I need it to do – there is a loop of all my posts except the ones in a particular category.
What I can’t figure out is making the part of the loop in the left column only display posts from the particular category.
// First part of loop in left column
// This is the only part that doesn't work the way I want
// This is the part I want to display posts from cat 39 only
<?php query_posts('showposts=1'); ?>
<?php $posts = get_posts('numberposts=1&offset=0'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count1 = 0; if ($count1 == "1" ) { break; } else { ?>
// Second part of loop in middle column
<?php query_posts('showposts=2'); ?>
<?php $posts = get_posts('numberposts=2&offset=0'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count2 = 0; if ($count2 == "2") { break; } else { ?>
<?php if (in_category('39') && !is_single() ) continue; ?>
// Third part of loop
<?php query_posts('showposts=2'); ?>
<?php $posts = get_posts('numberposts=2&offset=2'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count3 = 0; if ($count3 == "2") { break; } else { ?>
<?php if (in_category('39') && !is_single() ) continue; ?>
// Fourth part of loop
<?php query_posts('showposts=2'); ?>
<?php $posts = get_posts('numberposts=2&offset=4'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count4 = 0; if ($count4 == "2") { break; } else { ?>
<?php if (in_category('39') && !is_single() ) continue; ?>
// Fifth part of loop
<?php query_posts('showposts=2'); ?>
<?php $posts = get_posts('numberposts=2&offset=6'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count5 = 0; if ($count5 == "2") { break; } else { ?>
<?php if (in_category('39') && !is_single() ) continue; ?>
// Sixth part of loop - for titles/links only
<?php query_posts('showposts=8'); ?>
<?php $posts = get_posts('numberposts=8&offset=8'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count6 = 0; if ($count6 == "8") { break; } else { ?>
<?php if (in_category('39') && !is_single() ) continue; ?>
For anyone wondering, the reason for breaking it up into sections is I want other content between each part.
Again, all but the first part of the loop functions the way I want it to.
I tried using the same exclude stuff – one for each of the other categories but it still showed all the other posts. I don’t understand why that didn’t work either.