WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Thanks in advance.

I'd like to have posts with different colored borders and headers. It would be nice to choose a category of the post (red, blue, black, etc.) and have it change the class for that specific post.

If it were outside of dreamweaver, it would use classes.

So I could say:

<div class="red box">

Ideally this would work by having an option in the design view named 'classes' or 'post styles'. I would choose 'box' and 'red', and the style would be changed. Is this possible?

share|improve this question
up vote 1 down vote accepted

Use 'post_class' for custom CSS per post.

An example with 3 variations (only use 1):

 <div id="post-<?php the_ID(); ?>" class="red box" ?>>  //idea 1
 <div id="post-<?php the_ID(); ?>" <?php post_class('box-color'); ?>> //idea 2
 <div id="box-color" <?php post_class(); ?>> //idea 3


To be able to choose a color in the post, use a custom field conditional. http://codex.wordpress.org/Custom_Fields

To just change it based on category and such wrap the post class examples above in a category conditional. http://codex.wordpress.org/Conditional_Tags#A_Category_Page

The logic ( not proper code but ya):

     if in_category( array( 1,2,3 ) ) { 
       // add your custom post class div 
        // use default post class style.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.