• Resolved johnfotios

    (@johnfotios)


    Hi guys.

    I have a is_category ‘news’ going on, then a loop. Within the loop I want each post to display slightly different depending on which sub category of ‘news’ it is in.

    I thought this would be easy…

    <?php if (is_category('news')) :?>
    	<h1>Latest <?php single_cat_title(); ?></h1>
    	<?php while(have_posts()): the_post(); ?>
    		<?php if (is_category('news-1')) :?>
    			<p style="float:right;">Whatever if news-1</p>
    		<?php elseif (is_category('news-2')): ?>
    			<p style="float:right;">Whatever if news-2</p>
    		<?php elseif (is_category('news-3')): ?>
    			<p style="float:right;">Whatever if news-3</p>
    		<?php endif; ?>
    		<h3><?php the_title(); ?></h3>
    		<p>News article posted on: <strong><?php the_time('jS F Y') ?></strong></p>
    		<?php the_content(); ?>
    	<?php endwhile; ?>
    <?php endif; ?>

    It appears to just ignore my is_category within the loop though.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘is_category within a loop’ is closed to new replies.