• Resolved paul-davis

    (@paul-davis)


    Hello everyone.
     
    I’m building a quite complex site at the moment, and I’m having 2 problems with the conditional tags. I know how to use them, and have used them successfully in past designs. Here’s my problems:
     
    1, The current site I’m developing calls for a div to be loaded but only for it’s corresponding category. It works fine on the main parent category, but I also want it to show on each sub-category under the main one too. So I want it shown in site.com/category/services and site.com/category/services/more. In-fact every sub-category under the main one.
     
    Here’s the code I have now which is in the archive.php file:
     

    <?php if (is_category('services')) { ?>
    	<div id="services_panel">
    		<!-- Image is loaded from CSS -->
    		<p><?php echo category_description(get_category_by_slug('services')->term_id); ?></p>
    	</div>
    <?php } ?>

     
     
     
    2, The conditional statement which works in the loop just before the posts will not work outside the loop. I want to load a sidebar that corresponds to the category the page is displaying.

    Here’s that code too, also in the archive.php file.

    <?php else : ?>
    		<h2>Not Found</h2>
    	<?php endif; ?>
    
    	<div class="grid_4">
    		<?php if(is_category('services')) { ?>
    			<?php get_sidebar('services'); ?>
    		<?php } else { ?>
    			<p>if/else didnt work. =[</p>
    		<?php } ?>
    	</div>	
    
    <?php get_footer(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Conditional Tag Problems’ is closed to new replies.