Forums

[resolved] Using Conditional tags (3 posts)

  1. Theros
    Member
    Posted 1 year ago #

    Hi all!

    I've got a slight problem here. Here's some code I'm working on.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
     <div class="titles">
      <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <strong><h3><?php if (is_category('4')){
    		the_time('Y');
    	} else {
    		the_time('m.d.Y');
    	} ?></h3></strong>
    	</div>
        	<div class="storycontent">
    		<?php the_content(__('(Read More)')); ?>
    		</div>
    </div>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    My problem is why isn't the conditional statement doing its job and displaying only the year when the post is in category 4 or the entire date when its in category 5? Here's the page I'm working on. The Events tab is category 5 and the Projects tab is category 4.

    Thanks so much,
    Eric Huang

  2. moshu
    Member
    Posted 1 year ago #

    Try in_category because is_category is supposed to be used on cat archives...

  3. Theros
    Member
    Posted 1 year ago #

    Alright, thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic