I have a sidebar with several loops in it. Each loop looks something like this:
$temp = $the_query;
$the_query= null;
$the_query = new WP_Query;
$the_query->query('cat=54&showposts=1');
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_content(); ?>
<?php endwhile; ?>
<?php $the_query = null; $the_query = $temp; ?>
The problem is, I need to be able to hide one of these loops if I'm on a single post in the category '54'. So I added this:
<?php if (!( in_category('54') )) { ?>
... query loop ...
<?php } ?>
But it makes no change to what is outputted. Whether the post is in that category or not, it shows up.