Forums

When inserting post_class into single.php, sidebar gets shifted (6 posts)

  1. ilew
    Member
    Posted 1 year ago #

    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

    Thanks

  2. Aaron Wagner
    Member
    Posted 1 year ago #

    Is there a URL where we can see this?

  3. ilew
    Member
    Posted 1 year ago #

    Yea here is a link to a post LINK

  4. Aaron Wagner
    Member
    Posted 1 year ago #

    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)

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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-->

  6. ilew
    Member
    Posted 1 year ago #

    You guys are truly amazing. It's all fixed. Thanks so much for the help :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags