WordPress.org

Ready to get started?Download WordPress

Forums

Sidebar Issues (4 posts)

  1. jweigand
    Member
    Posted 9 years ago #

    Trying to get the sidebar to display on post pages... it works fine if the post has comments, but if it does not, the Sidebar does not display correctly. I've been able to narrow it down to a rogue <div> either closing incorrectly, or not closing at all, but my knowledge is somewhat limited, and I can't for the life of me figure it out. Any ideas?

    http://john.jvwdesigns.com

  2. jweigand
    Member
    Posted 9 years ago #

    My post file:

    <?php get_header(); ?>

    <!-- Begin #main -->
    <div id="main">

    <!-- Begin .post -->
    <?php $found=0; ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if (in_category(34) && !$single) { $found=1; ?>
    <ul class="linklog">

  3. <?php echo wptexturize($post->post_content); echo ' '; comments_popup_link('(0)', '(1)', '(%)' ) ?>
  4. <?php } else { ?>

    <?php if ($found == 1) { ?>
    <div style=" margin:.5em 0 1.5em; padding-bottom:1.5em; border-bottom:1px dotted #ccc;"></div>
    <?php $found =0;} ?>

    <h2><?php the_time('l, F jS, Y') ?></h2>
    <div class="post">
    <div class="post-title">
    " style="text-decoration:none;" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
    <?php the_title(); ?>

    </div>

    <div class="post-body">
    <div>
    <?php if($post->post_excerpt) { ?>
    <div class="post-excerpt"><?php the_excerpt(); ?></div>
    <?php } ?>
    <?php the_content(); ?>
    </div>
    </div>

    <p class="post-footer">
    <?php the_time() ?> Filed under <?php the_category(',') ?> #comments"><?php comments_popup_link(' 0 Comments', ' 1 Comment', ' % Comments', '', ''); ?><?php edit_post_link("edit", " ", ""); ?>

    <?php comments_template(); // Get wp-comments.php template ?>

    <?php } ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>
    <!-- End .post -->

    <?php if ($found == 1) { ?>
    <div style=" margin:.5em 0 1.5em; padding-bottom:1.5em; border-bottom:1px dotted #ccc;"></div>
    <?php $found =0;} ?>

    <div class="right"><?php posts_nav_link('','','previous »') ?></div>
    <div class="left"><?php posts_nav_link('','« newer ','') ?></div>

    </div>

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

  • jweigand
    Member
    Posted 9 years ago #

    Comments file:

    <div id="comments">

    <?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?>
    <?php _e('Enter your password to view comments.'); ?>
    <?php return; endif; ?>

    <dl id="comments-block">
    <?php if ( comments_open() ) : ?>
    <dd style="margin: 0px; padding: 0px;">
    <p style="margin: 0px; margin-bottom: 1em; padding: 0px;"><b><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?> so far</b>
    <?php else : // If there are no comments yet ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>

    ">Leave a comment
    <?php endif; ?>

    <?php if ( $comments ) : ?>

    <?php $myvar=0; ?>
    <?php foreach ($comments as $comment) : ?>
    <?php $myvar++; ?>
    <?php if ($myvar == 1) {$swap = "background-color: #eeeee6; padding: 5px;";} ?>
    ">
    <div class="commentBox" style="<?php echo $swap; ?>">

    <?php comment_text() ?>

    <p class="post-footer" style="margin-bottom: 0px; padding-bottom: 0px;">By <?php comment_author_link() ?> on <?php comment_date('m.d.y') ?> <?php comment_time() ?> <?php edit_comment_link(__("e"), ''); ?> | ">Permalink
    </div>

    <?php if ($myvar == 1) {$myvar = -1; $swap = "background-color: #e5e5e5; padding: 5px;";} ?>
    <?php endforeach; ?>

    </dd>
    </dl>

    <div class="right"><?php comments_rss_link(__('RSS feed for comments on this post.')); ?>
    <?php else : // If there are no comments yet ?>
    <?php endif; ?>

    <?php if ( pings_open() ) : ?>
    " rel="trackback"><?php _e('TrackBack URI'); ?>
    <?php endif; ?>
    </div>


    <?php if ( comments_open() ) : ?>
    <b><?php _e('Leave a comment'); ?></b>
    <?php _e("Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:"); ?> <?php echo allowed_tags(); ?>

    <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="15" tabindex="1" />
    <label for="author"><?php _e('Name'); ?></label> <?php if ($req) _e('(required)'); ?>
    <input type="hidden" name="comment_post_ID" value="<?php echo $post->ID; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" />

    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="15" tabindex="2" />
    <label for="email"><?php _e('E-mail'); ?></label> <?php if ($req) _e('(required)'); ?>

    <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="15" tabindex="3" />
    <label for="url"><?php _e('URI'); ?></label>

    <label for="comment"><?php _e('Your Comment'); ?></label>

    <textarea name="comment" style="border: 1px solid #000;" id="comment" cols="50" rows="9" tabindex="4"></textarea>

    <input name="submit" id="submit" type="submit" tabindex="5" value="<?php _e('Say It!'); ?>" />

    <?php do_action('comment_form', $post->ID); ?>
    </form>

    <?php else : // Comments are closed ?>

    <?php endif; ?>
    </div>

  • Lorelle
    Member
    Posted 9 years ago #

    First, please don't post long blocks of code. With the link to your site we can gather all the information we need about the CSS and XHTML on that page.

    Second, you have more problems than just a stray div. These need to be fixed. Which may also fix your problem.

    Third, consider a visit to the WordPress Codex to read Finding Your CSS Styles which will help you play detective to narrow down the problem.

    Fourth, when you change one building block on your site, you have to change all the rest. Make sure that your content area and comment area are narrow enough to accommodate the addition of the sidebar. Consider trying a small number of columns here:

    <label for="comment">Your Comment</label><br />
    <textarea name="comment" style="border: 1px solid #000;" id="comment" cols="50" rows="9" tabindex="4"></textarea>

    Change cols="50" to cols="40" or some lesser number and see if the sidebar jumps up.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.