Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

how to exclude posts from one category to not show on sidebar on homepage only when I explicitly dont want that particular post, in all other cases post will be displayed. I had try with plugin "WP Hide Post", but that seems to not working with sidebar, only for regular loop.I check on hide this post from homepage, and nothing happens. Any solutions?.Tnx.

This is the code I use to display post in homepage sidebar:

<?php query_posts('category_name=events&showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" accesskey="s"><?php the_title(); ?></a>
</h2>
<div class="myclass3"><?php wpe_excerpt('wpe_excerptlength_index', 'wpe_excerptmore'); ?>                        </div><BR>
<?php endwhile; ?>
share|improve this question

1 Answer

I'm not sure if this is what you're looking for, but you could just wrap everything INSIDE the while/endwhile with a

<?php if(! in_category( array( [category_id] ) )) ?>

   ....your code here to display the rest of the categories.....

<?php endif; ?>

Just replace [category_id] with the category you are looking to exclude

share|improve this answer
Tnx for answer, but this not what I want.Im searching for solution to manualy enable post from certain category to show or not on sidebar, eg. checkbox in edit post screen say:do not include this on homepage.Plugin "wp hide post" does that, but not work on sidebar, only for regular loop. – user4490 Mar 7 '12 at 9:37

protected by toscho Jun 11 '12 at 11:51

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.