Feature post on home and hiding category problem
-
I know, this has been up a million times but I just can’t find a solution that works!
I want to display a post from the featured category at the top of the page, but I don’t want the featured category to be visible anywhere else, ever. Not in searches or anything, just the one time when it’s on top at the front page.
Here’s my code.
<?php $temp_query = $wp_query; ?>
<?php query_posts('category_name=featured&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="frontpage">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php $wp_query = $temp_query; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); if (in_category('9')) continue; ?>
(postlisting goes here)
<?php endwhile; ?>
(next/previous goes here)
<?php else : ?>
(didn’t find anything goes here)
<?php endif; ?>
Every solution I’ve found either messes up the listing by not having the right amount of items in it (excluding the category does that), or I don’t manage to exclude the category and it looks bad.
Please help. I’ve been at this for a couple of days now, searching the forums and looking at The Loop page in the codex without any luck.
- The topic ‘Feature post on home and hiding category problem’ is closed to new replies.