• Hi all, I am in the process of developing a new theme and would like to display the content of my category pages in two columns side my side with the posts being listed in the columns by date order.

    I have started to dev a custom category template, but am having trouble with the code to display the posts in the two columns, the code I have so far is as follows:

    <?php get_header(); ?>
    
    	<div id="content">
    
    		<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    		<div class="post">
    				<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    				<small><?php the_time('l, F jS, Y') ?></small>
    
    				<div class="entry">
    					<?php the_excerpt() ?>
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Any help you can give me will be greatfully received, thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Assuming that you want the posts to be displayed vertically in 2 columns ( ie complete the left column, then switch to the right column), I think you many need to use more than 1 Loop:

    http://codex.wordpress.org/The_Loop#Multiple_Loops

    If you want the posts to display left-right-left-right, you could use a single Loop and just float the post containers using CSS.

    Thread Starter drgizmondo

    (@drgizmondo)

    @esmi thanks for the quick responce I have fixed this issue, but was wondering if you could help me with a related problem. On mu hopepage I have a section at the top that displayes a large feature post image, bellow this I want to list all posts again in two columns but excluding cats 16 and 17. I have been able to do this, but have been unable to get it into two columns. Can you please take a look at my code and show me how to do this as I dont want to break the code I have already writen.

    <?php get_header(); ?>
    
    <?php if (have_posts()) : ?>
    
    	<div id="content">
    
        <!-- FEATURED CONTENT LOOP -->
    
    <div id="feat_section">
    		  <?php $my_query = new WP_Query('category_name=feature&posts_per_page=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
    
                            <div class="feat_title">
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
                              </div>
    
    <div class="post_author">
    <p>By: <?php the_author_posts_link(); ?> | <?php the_date(); ?> | <?php the_time(); ?></p>
    
    </div>
    
    				<div class="entry">
    
    <?php if( get_post_meta($post->ID, "thumb", true) ): ?>
    <div class="homethumb">
    <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=350&w=624&zc=0" alt="<?php the_title(); ?>" width="624" height="350" />
    </div>
    <?php else: ?>
    <?php endif; ?>
    
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    </div>
    
        <!--NEWS POSTS LOOP -->	
    
    <div id="news_section">
    
    <?php
       if (is_home()) {
          query_posts("cat=-16,-17,");
       }
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
     <div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
                                     <?php the_excerpt(); ?>
    				</div>
    
    			</div>
      <?php endwhile; endif; ?>
    
    </div>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display categories in 2 two columns’ is closed to new replies.