treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Comments Template Not Being Recognized as Part of DIV? (WP)

  • I've been hammering this question out over at stackoverflow with some folks: http://stackoverflow.com/questions/7478500/jquery-or-css-problem

    Take a look here to see the problem: http://themeforward.com/demo2/2011/01/17/testing-comments/comment-page-1/#comments

    I am using a javascript to make the height of #post_content and #sidebar match. I have figured out the problem is it works perfectly, but once the comments template is added to my single-post.php it all falls apart and the heights no longer match (as shown in the link). What do I have to do to make this code realize comments.php is wrapped by post_content!?


    Here is my javascript:
    <script type='text/javascript'>
    function resizeIt() {
    console.log("post_content.outerheight: " + $('#post_content').height() + ", sidebar.height: " + $('#sidebar').height());
    if($('#post_content').outerHeight(true) > $('#sidebar').height()) {
    $('#sidebar').height($('#post_content').outerHeight(true)+'px');
    }
    }

    $(document).ready(function() {
    resizeIt();
    $('#post_content').resize(resizeIt());
    });
    </script>



    CSS that may/may not play a role:
    #container {
    width: 1126px;
    clear: both;
    overflow: hidden;
    }
    #post_content {
    clear: both;
    display: block;
    float: left;
    overflow: hidden;
    width: 660px;
    background-color: #FF0000;
    }
    #sidebar {
    display: inline-block;
    float: right;
    width: 410px;
    overflow: hidden;
    background-color: #0000FF;
    }
    #respond {
    clear:both
    }
    #commentlist {
    list-style:none;
    width:100%
    }


    My markup:
    <?php get_header(); ?>

    <div id="container">
    <div id="post_content">




    <!-- Grab posts -->
    <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>

    <!-- Breadcrumbs -->
    <?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>

    <!-- Avatar -->
    <span class="post_avatar">
    <a href="<?php echo get_bloginfo('url') . '/author/' . get_the_author_meta('login'); ?>">
    <?php echo get_avatar( get_the_author_email(), '50' ); ?>
    </a>
    </span>

    <!-- Title -->
    <h1 class="post">
    <?php the_title(); ?>
    </h1>

    <!-- Post time, author, category -->
    <span class="sub-title-post">By <?php the_author_posts_link( ); ?> <span class="sub-title-divider">|</span> <?php the_time('F j, Y'); ?> <span class="sub-title-divider">|</span> <a href="#commentlist"><?php comments_number( 'No comments', 'One comment', '% comments' ); ?></a>
    </span>


    <!-- The post -->
    <?php the_content(); ?>

    <!-- Tags -->
    <div class="tag_spacer">

    <h3 class="tags">
    <?php the_tags('Tags ',' / ','<br />'); ?>
    </h3>

    <h3 class="tags">
    <?php $turl = getTinyUrl(get_permalink($post->ID));
    echo 'Short URL <a href="'.$turl.'">'.$turl.'</a>' ?>
    </h3>
    </div>


    <!-- Next/Previous Posts -->
    <div class="mp_archive2">
    <div id="more_posts">
    <div class="oe">
    <?php previous_post_link('%link', '« Previous post', TRUE); ?>
    </div>

    <div class="re">
    <?php next_post_link('%link', 'Next post »', TRUE); ?>
    </div>
    </div>
    </div>

    <?php comments_template(); ?>

    </div>


    <?php endwhile; else: ?>
    <p>No matching entries found.</p>
    <?php endif; ?>

    <?php get_sidebar(); ?>
    </div>
    </div>
    </div>
    <?php get_footer(); ?>