Hi everyone
Please bear with me I'm new to php.
I'm using a conditional statement to change the contents of a sidebar for a certain category. The 'if is_category' bit works OK but it doesn't work for posts that are in sub-categories (children) of the main category. I tried in_category('child_of=16') but that doesn't seem to work. I'd be very grateful of any help.
Thanks
<?php if (is_category('16') or in_category('16') or in_category('child_of=16')) { ?>
<?php wp_list_cats('child_of=16'); ?>
<?php } else { ?>
<?php while(have_posts()) : the_post(); ?>
<?php foreach((get_the_category()) as $category)
{ $my_query = new WP_Query('category_name=' . $category->category_nicename . '&orderby=title&order=asc&showposts=100');} ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php break; endwhile; ?>
<?php } ?>