Title: Category class
Last modified: August 20, 2016

---

# Category class

 *  Resolved [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/)
 * Hi,
    I have one problem. It’s about CSS class of posts. All of my posts have 
   same class , but only one category have a different. How I can , change that?
   I want to know , how to other categories have different class like that one? 
   or How that category have same class as others…
 * > [View post on imgur.com](https://imgur.com/492Ks)

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483094)
 * what theme are you using?
 * can you post a link to your site?
 *  Thread Starter [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483104)
 * It’s custom built theme.
    Site [http://skyinx.com/blog](http://skyinx.com/blog)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483125)
 * your theme info says it is based on Twenty Ten;
 * possibly look for loop.php of your theme;
 * look for a line with `<div class="post`… and some more code;
    edit this accordingly.
 * or possibly paste the full code of loop.php into a [http://pastebin.com/](http://pastebin.com/)
   and post the link to it here.
    someone might have look at it and might be able
   to make some useful suggestions.
 * and also try to contact who ever build that theme for you – this might be easier
   and faster.
 *  Thread Starter [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483131)
 * [http://pastebin.com/eEsqRuKn](http://pastebin.com/eEsqRuKn)
    I made that theme
   from this [http://starkerstheme.com/](http://starkerstheme.com/) theme…
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483133)
 * close to the beginning of the code, see these lines:
 *     ```
       <?php if ( in_category('3') ) { ?>
                  <div class="post-cat-three">
        <?php } else { ?>
                  <div class="post">
        <?php } ?>
       ```
   
 * define what you would like instead, and edit the code.
 * edit:
    the style.css does not seem to have any styles for `.post-cat-three` –
   therefore you could simplyfy the above code:
 *     ```
       <div class="post">
       ```
   
 *  Thread Starter [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483144)
 * `in_category('3')`
 * Hmm when I delete this number , then all works fine with `.post` class.
    But 
   I want to know what this number “in my case 3” do? Is it the number of category?
   If it is how to know number of category?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483152)
 * yes – 3 is the category ID of your category ‘inspiration’ or so.
 * to find the category IDs of your categories, goto
    _**dashboard – posts – categories**_;
   and hover over the category names in the list, then look at the address bar at
   the bottom of the browser: it will show `........&tag_ID=3&.....` where 3 is 
   the category ID of the category where the mouse pointer hovers over.
 * [http://codex.wordpress.org/Function_Reference/in_category](http://codex.wordpress.org/Function_Reference/in_category)
 *  Thread Starter [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483155)
 * Ok Thank You.
    I think this will be last question 😀 How to add more of categories.
   I tried:
 * >  <?php if ( in_category(‘3’) ) { ?>
   >  <div class=”post-cat-three”> <?php if (
   > in_category(‘4’) ) { ?> <div class=”post-cat-four”> <?php } else { ?> <div 
   > class=”post”> <?php } ?>
 * then I tried:
 * >  <?php if ( in_category(‘3’) ) { ?>
   >  <div class=”post-cat-three”> <?php **else**(
   > in_category(‘4’) ) { ?> <div class=”post-cat-four”> <?php } else { ?> <div 
   > class=”post”> <?php } ?>
 * It doesn’t work…
    How to add more categories with different class?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483185)
 *     ```
       <?php if ( in_category('3') ) { ?>
       <div class="post-cat-three">
       <?php  } elseif ( in_category('4') ) { ?>
       <div class="post-cat-four">
       <?php } else { ?>
       <div class="post">
       <?php } ?>
       ```
   
 * structure:
 *     ```
       if
       elseif
       elseif /*repeated as often as needed*/
       else
       ```
   
 * [http://php.net/manual/en/control-structures.elseif.php](http://php.net/manual/en/control-structures.elseif.php)
 *  Thread Starter [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * (@kejnav)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483191)
 * RESPECT!
    Thank YOU SO MUCH! [http://media.tumblr.com/tumblr_lw4p0trGje1qld7g2.gif](http://media.tumblr.com/tumblr_lw4p0trGje1qld7g2.gif)

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

The topic ‘Category class’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [class](https://wordpress.org/support/topic-tag/class/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [problem](https://wordpress.org/support/topic-tag/problem/)

 * 10 replies
 * 2 participants
 * Last reply from: [KEJNAV](https://wordpress.org/support/users/kejnav/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/category-class/#post-2483191)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
