Assistance with Loop and PHP
-
I’m using this loop in an attempt to get three posts that have images. I believe the issue has something to do with the way I’m incrementing $varz or the way the While statement is setup. Using this code currently returns a blank page with no content. Any help is much appreciated.
<div class="featured-sidebar first"> <?php $varz = 1 ?> <?php query_posts( 'cat=32,45,46,43,44,104,23,31,36&posts_per_page=20') ?> <?php if ( have_posts() ) : while ( $varz < 4 ) : the_post(); ?> <?php if ( has_post_thumbnail() ) {?> <?php if ($varz = 1){ echo"<img class=\"most-pop-overlay1\" src=";print IMAGES;echo"/images/one-overlay.png\" />"; } elseif ($varz = 2){ echo"<img class=\"most-pop-overlay2\" src=";print IMAGES;echo"/images/two-overlay.png\" />"; } elseif ($varz = 3){ echo"<img class=\"most-pop-overlay3\" src=";print IMAGES;echo"/images/three-overlay.png\" />"; } else{} ?> <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(150,150)); ?></a> <h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2> <p> <?php $exc = strip_tags(get_the_excerpt()); ?> <?php echo string_limit_words($exc,12); ?>... </p> <?php $varz++; ?> <?php } ?> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query() ?> </div>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Assistance with Loop and PHP’ is closed to new replies.