Title: Incorporating post-class into this code
Last modified: August 21, 2016

---

# Incorporating post-class into this code

 *  [cleverchick](https://wordpress.org/support/users/cleverchick/)
 * (@cleverchick)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/incorporating-post-class-into-this-code/)
 * I have the following in my template:
 * `<?php if (have_posts()) : while (have_posts()) : the_post(); ?>`
 * How do I incorporate post_class into this?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/incorporating-post-class-into-this-code/#post-4379713)
 * Try reviewing the examples in [http://codex.wordpress.org/Function_Reference/post_class](http://codex.wordpress.org/Function_Reference/post_class)
 *  Thread Starter [cleverchick](https://wordpress.org/support/users/cleverchick/)
 * (@cleverchick)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/incorporating-post-class-into-this-code/#post-4379726)
 * Yes, I have looked through there. I am not a coder, and have tried inserting 
   it in several different ways, to no avail. The closest I got was just
 *     ```
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
           <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       ```
   
 * Which formats ALL of the posts like the sticky post is supposed to be.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/incorporating-post-class-into-this-code/#post-4379766)
 * Try:
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       ```
   

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

The topic ‘Incorporating post-class into this code’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/incorporating-post-class-into-this-code/#post-4379766)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
