• Hi,

    Sorry I feel like a complete dunce posting this here. I started working on a new sidebar for a site I’m working on, which would have features in the sidebar sitewide, and then category specific content underneath that, using the in_category tag.

    This was all working fine when I was testing it, but then broke when I changed what posts were tagged with ‘feature’ (and so called in the top loop.

    I’ve been looking at the code now for several hours, changing bits and pieces here and there. The content specific to the news comes if I take out the if in_category ’33’ statement, but of course that would render the sidebar useless… But I think it’s got to be somewhere in the if elseif statements that it’s going wrong.

    Or is there another way of creating the conditions at the bottom?
    Any help would be really appreciated!
    thanks,
    edd

    <div id="main_sidebar">
    <div class="features">features</div>
    <div class="recommended">Recommended</div>
    
    <p> <?php $temp_query = clone($wp_query); ?>
    <?php query_posts('showposts=5&tag=feature'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php
    // getting the image
    $image = get_post_meta($post->ID, 'image_index', $single = true);
    ?>
    
    <div class="sidebar_feature">
    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    	<div class="featureimage">
    	<a href="<?php the_permalink() ?>">
    <?php
    // putting image in
    if($image !== '') {
    echo '<img src=" ' . $image . '" height="103px" width="290px" />';
    			}
    else { echo '<img src="../images/butterflies-index-image-white.jpg" width="290" height="103" />';
    				}
    ?></a><br />
    </div></div></p>
    	<?php endwhile; endif; ?>
    		<?php $wp_query = clone($temp_query); ?>
    
    <!-- featured sidebar will sit below here -->
    <!-- SPECIFIC CATEGORY SIDEBAR STUFF GOES HERE -->
    
    <?php if (in_category('33') ) : ?>
    
    <!-- this is the NEWS SIDEBAR -->
    
    <div class="features" style="text-align:left; padding-left: 12px;">Latest news</div>
    <div id="news_sidebar">
    	<p><?php $temp_query = clone($wp_query); ?>
    	<?php query_posts('showposts=8&cat=33'); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php
    // getting the image
    $image = get_post_meta($post->ID, 'image', $single = true);
    ?>
    
    <div class="newspost_sidebar">
    <a href="<?php the_permalink() ?>">
    <?php
    // putting image in
    	if($image !== '') {
    echo '<img src=" ' . $image . '" width="50" height="50" />'; }
    else { echo '<img src="../images/related-image-holder.jpg" width="50" height="50" />'; 	}
    	?></a>
    
    <h4 style="text-align: left"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h4>
    <div class="spacer"></div>
    <span class="date"><?php the_time('d.m.y') ?></span> <span class="author"><?php the_author_posts_link(); ?></span><br />
    </div><div class="clear_sidebar"></div>
    <?php endwhile; endif; ?></div>
    <?php $wp_query = clone($temp_query); ?>
    
    	<?php elseif (in_category('9') ) : ?>
    	do something
    	<?php endif; ?>
    </div>
  • The topic ‘conditional sidebar in_category not showing’ is closed to new replies.