0
votes

I'm using Foundation for a wordpress theme and I need to wrap two posts into one div with class of 'row'. The thing is I need to put div class="row" before the first post closing the the second post with div and it should repeat with every new posts.

Here is my code:

<?php query_posts( 'cat=2&showposts=9&orderby=date&order=DESC' ); ?>
<div <?php post_class('small-12 medium-6 large-6 columns') ?> id="post-<?php the_ID(); ?>">

    <?php echo '<a href="', get_permalink(), '">';
        if ( has_post_thumbnail() ) {the_post_thumbnail();}
        else { echo '<img src="', get_template_directory_uri( 'template_directory' ), '/images/thumb-default.png','" alt="" />'; }
        echo '</a>';
    ?>

    <a href="<?php echo get_permalink(); ?>"><h3><?php the_title(); ?></h3></a>
    <p><?php echo get_excerpt(); ?></p>     

</div>
1

1 Answers

0
votes

something like this i think

<?php
$count = 1;
$outputstring = "";
ur while loop 

if ( $count % 2 != 0 )
{
$outputstring .= " <row div>";
}

$outputstring .= "<div" . post_class('small-12 medium-6 large-6 columns'). ' id="post-'. the_ID() .'>';

    YOUR OUTPUT CODE HERE


if ( $count % 2 == 0 )
{
$outputstring .= " </end row div>";

}
$count++;


END your while loop

echo $outputstring; /// here is where u output the WHOLE thing outside of your loop
?>