Title: When inserting post_class into single.php, sidebar gets shifted
Last modified: August 20, 2016

---

# When inserting post_class into single.php, sidebar gets shifted

 *  [ilew](https://wordpress.org/support/users/ilew/)
 * (@ilew)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/)
 * After just figuring how to style posts from a specific category using post_class
   I inserted the following code into my single.php file
    `<div id="post-<?php the_ID();?
   >" <?php post_class(); ?>>`
 * I then added .category-blog to my CSS which allowed me to independently style
   all posts with the category “blog”.
 * However wherever I seem to insert
    `<div id="post-<?php the_ID(); ?>" <?php post_class();?
   >>` into single.php, the sidebar of the site gets shifted to the bottom of the
   page when looking any single post. Does anyone have any ideas?
 * Here is the link to the code for single.php currently
 * [SINGLE.PHP](http://pastebin.com/YgLf0rGk)
 * Thanks

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

 *  [Aaron Wagner](https://wordpress.org/support/users/ajwagner777/)
 * (@ajwagner777)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186725)
 * Is there a URL where we can see this?
 *  Thread Starter [ilew](https://wordpress.org/support/users/ilew/)
 * (@ilew)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186731)
 * Yea here is a link to a post [LINK](http://www.geekymedics.com/blog/guess-what-we-finally-have-a-blog/)
 *  [Aaron Wagner](https://wordpress.org/support/users/ajwagner777/)
 * (@ajwagner777)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186737)
 * ok, it looks like there are a couple of things going here. I think you have your
   sidebar div inside your main-container div. I don’t know if that was intentional
   or not. I would guess no because your width is set to 540 on the main-container,
   so it’d be my guess that it needs to go outside.
 * (I played with the layout a little in firebug and I suspect that’s the reason
   for the error)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186738)
 * when you insert this:
 *     ```
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       ```
   
 * you are effectively opening a new div – which you need to close as well –
    add:`
   </div>` before this line: `</div><!--post-content-->`
 *  Thread Starter [ilew](https://wordpress.org/support/users/ilew/)
 * (@ilew)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186742)
 * You guys are truly amazing. It’s all fixed. Thanks so much for the help 🙂

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

The topic ‘When inserting post_class into single.php, sidebar gets shifted’ is closed
to new replies.

 * 5 replies
 * 3 participants
 * Last reply from: [ilew](https://wordpress.org/support/users/ilew/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/when-inserting-post_class-into-singlephp-sidebar-gets-shifted/#post-2186742)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
