Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112476

alchymyth on "Put posts into divs?"

$
0
0

well done so far.

your logic for adding the .portfolio-item div is not needed with my suggestion; the div can be added normally into the loop;

example:

<?php $count  = 0;
query_posts('cat=1');
if(have_posts()) : while(have_posts()) : the_post();
//open the wrapper div for three posts//
if( $count%3 == 0 ) echo "\n".'<div class="row">'; ?>

<div class="span4 portfolio-item">
<div class="loopcontent">
        <a>">
			<?php
				if ( has_post_thumbnail() ) {
					the_post_thumbnail('full');
				} else {
					// the current post lacks a thumbnail
				}
?></a>
                <h2><a>"><?php the_title(); ?></a></h2>
				<?php the_excerpt(); ?>
        </div>
</div><!--/ .span4 portfolio-item -->
<?php
//close the wrapper div for three posts//
if( $count%3 == 2 ) echo "\n".'</div><!-- .row -->';
$count++;
endwhile;
//close the wrapper div if less than three posts//
if( $count%3 != 0 ) echo "\n".'</div><!-- .row -->';
endif;
?>

caveat:
your posted code is partialy broken - particular the '<a href=' parts - and what I posted is broken as well; so do not use it for copy/paste, but just take the structure from it.


Viewing all articles
Browse latest Browse all 112476