Title: Conditional CSS for individual posts
Last modified: August 18, 2016

---

# Conditional CSS for individual posts

 *  [JaneLitte](https://wordpress.org/support/users/janelitte/)
 * (@janelitte)
 * [19 years ago](https://wordpress.org/support/topic/conditional-css-for-individual-posts/)
 * I don’t know if I can do this, but I want to be able to show different css styling
   for select posts on a category or archive page.
 * On my category pages, as can be seen here, I want to be able to add a category
   to a specific post and have it show “recommended” on the category page.
 * I thought I could do a conditional is_category statement like this but wasn’t
   sure
 * `<?php /* If this is a category archive */ if (is_category('recommended')) {`
 * `<div class="special"><?php while (have_posts()) : the_post(); ?>`
 *     ```
       <?php echo wptexturize(the_excerpt_reloaded()); ?>
       <code><?php endwhile; ?></code>
       </div>
   
       <code>} else {</code>
       <code><div class=&quot;regular&quot;><?php while (have_posts()) : the_post(); ?></code>
       ```
   
 * <?php echo wptexturize(the_excerpt_reloaded()); ?>
    `<?php endwhile; ?>` `</div
   >` `}` `?>`
 * Is this possible or should I use the in_category v. the is_category?
 * Is there a limit to how many conditional if statements I can have in one php 
   file? I know my questions sound very rudimentary.

The topic ‘Conditional CSS for individual posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [JaneLitte](https://wordpress.org/support/users/janelitte/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/conditional-css-for-individual-posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
