Title: Styling some posts differently
Last modified: August 18, 2016

---

# Styling some posts differently

 *  Resolved [Thord D. Hedengren](https://wordpress.org/support/users/tdh/)
 * (@tdh)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/styling-some-posts-differently/)
 * I’m fiddling around with a new project and got the brilliant idea to style some
   post differently. This is something I’ve seen others do, at [http://www.binarybonsai.com](http://www.binarybonsai.com)
   for instance, so is there a plugin or nice CSS/theme thing to do here?
 * (I want some posts to be more visible than others – larger fonts, other background
   and such.)
 * Thanks!

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

 *  [David Yeiser](https://wordpress.org/support/users/davedotcom/)
 * (@davedotcom)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/styling-some-posts-differently/#post-452794)
 * There are probably several different ways to do this. I’m not aware of a plugin,
   but I think it would just be easier to figure out how you want to identify the
   posts as being unique and then assign them a class and style that class differently
   in your style.css file.
 * For example, if you wanted to style the posts by category you could do the following:
 * `<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
   
    **  
   <div class=" <?php foreach((get_the_category()) as $cat) { echo $cat->category_nicename;}?
   >">
 * `
    <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php endwhile;
   else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php 
   endif; ?>
 * This spits out the post’s category slug as a class for each post’s div. Having
   done that, then you can just set up your style sheet to style accordingly.
 * You can read more about get_the_category() here:
    [http://codex.wordpress.org/Template_Tags/get_the_category](http://codex.wordpress.org/Template_Tags/get_the_category)
 * I don’t have a way to test this to see if it actually worked, so let me know.
 *  [David Yeiser](https://wordpress.org/support/users/davedotcom/)
 * (@davedotcom)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/styling-some-posts-differently/#post-452796)
 * I forgot to mention, you’ll probably want to put a space after the category slugs
   when you’re echoing those. That way if you have a post assigned to three categories
   the output will be
 * `<div class="category1 category2 category3">`
 * and not
 * `<div class="category1category2category3">`
 * To do this change the line in the above post where it reads
 * `echo $cat->category_nicename; `
 * to
 * **
    `echo $cat->category_nicename . ' ';`
 *  Thread Starter [Thord D. Hedengren](https://wordpress.org/support/users/tdh/)
 * (@tdh)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/styling-some-posts-differently/#post-452797)
 * It worked like a charm, thanks! 🙂

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

The topic ‘Styling some posts differently’ is closed to new replies.

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [Thord D. Hedengren](https://wordpress.org/support/users/tdh/)
 * Last activity: [19 years, 9 months ago](https://wordpress.org/support/topic/styling-some-posts-differently/#post-452797)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
