WordPress.org

Ready to get started?Download WordPress

Forums

Making sidebar stay put (3 posts)

  1. be-jc
    Member
    Posted 5 years ago #

    I been working on my blog category template and i'm having trouble making the sidebar stay up the top on the right.

    It gets pushed down by the content/post. I've tried to place the <?php get_sidebar();?> code before the post and it stays there but cuts off the posts and comments.

    This is happening both on my category template and singles template.

    Heres my link http://www.beyondempty.net/site/category/blog/

    Heres my code for the category template

    <?php get_header(); ?>
    
    <!-- BEGIN content -->
    <div id="content">
    
    	<div class="buffer">
    
    	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    	<?php /* If this is a category archive */ if (is_category()) { ?>
    	<h2 class="title">Welcome to my Personal <strong><?php single_cat_title(); ?></strong>.</h2>
    	<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    	<h2 class="title">Posts Tagged <strong><?php single_tag_title(); ?></strong></h2>
    	<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    	<h2 class="title">Archive for <?php the_time('F jS, Y'); ?></h2>
    	<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    	<h2 class="title">Archive for <?php the_time('F, Y'); ?></h2>
    	<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    	<h2 class="title">Archive for <?php the_time('Y'); ?></h2>
    	<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    	<h2 class="title">Author Archive</h2>
    	<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) &amp;&amp; !empty($_GET['paged'])) { ?>
    	<h2 class="title">Blog Archives</h2>
    	<?php } ?>
    
    	<?php
    	if (have_posts()) :
    	while (have_posts()) : the_post();
    	?>
    
    	<!-- begin post -->
    
    	<div class="blogpost">
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="date">Posted by: <?php the_author_posts_link(); ?> on <?php the_time('d F, Y') ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
    		<div class="postcont">
    		<p ><?php echo dp_clean($post->post_content, 250); ?></p>
    		<a class="readmore" href="<?php the_permalink(); ?>">Read More</a>
    		</div>
    		<div class="thumb"><a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a></div>
    
    	</div>
    
    	<!-- end post -->
    
    	<?php endwhile; ?>
    	<p class="postnav">
    		<?php next_posts_link('&laquo; Older Entries'); ?> &nbsp;
    		<?php previous_posts_link('Newer Entries &raquo;'); ?>
    	</p>
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar();?> </div> <?php get_footer(); ?>

    and my singles template

    <?php get_header(); ?>
    
    <!-- BEGIN content -->
    <div id="content">
    
    	<div class="buffer">
    
    	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    	<?php /* If this is a category archive */ if (is_category()) { ?>
    	<h2 class="title">Archive for the <strong><?php single_cat_title(); ?></strong> Category</h2>
    	<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    	<h2 class="title">Posts Tagged <strong><?php single_tag_title(); ?></strong></h2>
    	<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    	<h2 class="title">Archive for <?php the_time('F jS, Y'); ?></h2>
    	<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    	<h2 class="title">Archive for <?php the_time('F, Y'); ?></h2>
    	<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    	<h2 class="title">Archive for <?php the_time('Y'); ?></h2>
    	<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    	<h2 class="title">Author Archive</h2>
    	<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) &amp;&amp; !empty($_GET['paged'])) { ?>
    	<h2 class="title">Blog Archives</h2>
    	<?php } ?>
    
    	<?php
    	if (have_posts()) : the_post();
    	?>
    
    	<!-- begin post -->
    	<div class="single">
    		<h2><?php the_title(); ?></a></h2>
    		<p class="date">Posted by: <?php the_author_posts_link(); ?> | on <?php the_time('d F, Y') ?></p>
    		<?php the_content(); ?>
    	</div>
    	<!-- end post -->
    
    	<!-- begin comments -->
    	<div id="comments">
    	<?php comments_template(); ?>
    	</div>
    
    	<!-- end comments -->
    
    	<?php endif; ?>
    
    	</div>
    
    </div>
    <?php get_sidebar();?>
    </div>
    <!-- END content -->
    <?php get_footer(); ?>

    Any help would be much appreciated!

  2. be-jc
    Member
    Posted 5 years ago #

    I've had a bit of luck with this. The category section is working fine now.

    Now with the singles template there seems to be conflict between comments and sidebar.

    If i remove <?php get_sidebar(); ?> from the template the comments will show but having the sidebar means the comments don't show.

    Also now all of a sudden every post is replaced by the newest post. How did this happen?

    Please check link http://www.beyondempty.net/site/category/blog/

    Current singles.php template

    <?php get_header(); ?>
    
    <!-- BEGIN content -->
    <div id="content">
    
    	<div class="buffer">
    
    	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    	<?php /* If this is a category archive */ if (is_category()) { ?>
    	<h2 class="title">Archive for the <strong><?php single_cat_title(); ?></strong> Category</h2>
    	<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    	<h2 class="title">Posts Tagged <strong><?php single_tag_title(); ?></strong></h2>
    	<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    	<h2 class="title">Archive for <?php the_time('F jS, Y'); ?></h2>
    	<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    	<h2 class="title">Archive for <?php the_time('F, Y'); ?></h2>
    	<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    	<h2 class="title">Archive for <?php the_time('Y'); ?></h2>
    	<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    	<h2 class="title">Author Archive</h2>
    	<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) &amp;&amp; !empty($_GET['paged'])) { ?>
    	<h2 class="title">Blog Archives</h2>
    	<?php } ?>
    	<?php get_sidebar();?>
    	 <?php if (have_posts()) : ?>
    
                   <?php while (have_posts()) : the_post(); ?>
    
    	<!-- begin post -->
    	<div class="single">
    		<h2><?php the_title(); ?></a></h2>
    		<p class="date">Posted by: <?php the_author_posts_link(); ?> | on <?php the_time('d F, Y') ?>
    
    		<?php the_content(); ?>
    
    	</div>
    	<!-- end post -->
    
    	<!-- begin comments -->
    	<div id="comments">
    	<?php comments_template(); ?>
    	</div>
    
    	<!-- end comments -->
    	<?php endwhile; ?>
    
    	<?php endif; ?>
    
    		</div>
     </div></div> <?php get_footer(); ?>
  3. be-jc
    Member
    Posted 5 years ago #

    Bump, i don't know why all the posts are the same and instead of showing one post it shows all 4 in one single thread, can anyone explain why this is happening?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.