Title: Using Conditional tags
Last modified: August 19, 2016

---

# Using Conditional tags

 *  Resolved [theros](https://wordpress.org/support/users/theros/)
 * (@theros)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/using-conditional-tags/)
 * 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](http://www.childrenofkibera.org/). The Events
   tab is category 5 and the Projects tab is category 4.
 * Thanks so much,
    Eric Huang

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

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/using-conditional-tags/#post-680799)
 * Try **in**_category because is_category is supposed to be used on cat archives…
 *  Thread Starter [theros](https://wordpress.org/support/users/theros/)
 * (@theros)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/using-conditional-tags/#post-680802)
 * Alright, thanks so much!

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

The topic ‘Using Conditional tags’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [conditional tags](https://wordpress.org/support/topic-tag/conditional-tags/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [theros](https://wordpress.org/support/users/theros/)
 * Last activity: [18 years, 2 months ago](https://wordpress.org/support/topic/using-conditional-tags/#post-680802)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
