Feature post on home and hiding category problem (2 posts)

  1. Thord D. Hedengren
    Posted 10 years ago #

    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(); ?>

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

  2. Thord D. Hedengren
    Posted 10 years ago #

    Upping this one as it has fallen of the front page of the forum already.

    Hasn't anyone solved this?

Topic Closed

This topic has been closed to new replies.

About this Topic