Question : Pulling recent posts in two columns

I am working on this page: http://shelburnehealthandfitness.com/wordpress/

At the bottom you will see the recent news box, I am trying to get it for it displays 2x2 not straight down.

Any ideas how I can get it to display the recent posts  in a 2x2 format? I would need to add some conditionals correct?

Thanks,

Ryan

Answer : Pulling recent posts in two columns

I found this article: http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/

I tested out the first option on that page, but had to make adjustments to the php part to get it to work correctly, which I added below. If that works for you, then you can just make styling adjustments from that.

You also might want to try out the second option there, it might work out to be simpler.

(And if you want to only display a certain amount of posts, just add an extra conditional such as && ($i < 6) (which would only allow 3 to show).


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
<div align="center"><div style="width: 500px; text-align: left;">
<div id="left-column">
<?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?>
<h2><?php the_permalink(); ?></h2>
<?php the_excerpt(); ?>
<br /><br />
<?php endif; endwhile; else: ?>
<div>Alternate content</div>
<?php endif; ?>
</div>

<?php $i = 0; rewind_posts(); ?>

<div id="right-column">
<?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?>
<h2><?php the_permalink(); ?></h2>
<?php the_excerpt(); ?>
<br /><br />
<?php endif; endwhile; else: ?>
<div>Alternate content</div>
<?php endif; ?>
</div>
</div></div>
Random Solutions  
 
programming4us programming4us