• Hello all. i have three posts. each w/a a set img.
    but when i display the page only two of the three images show and it is off by one. so the image for the first post display instead for the second post. The image for the second post shows up for the third post instead.
    have not run into this before and the code looks correct.
    Has anyone else run into this issue? how do i go about solving this one?

    <div class="col-md-3 col-sm-12 col-xs-12">
    			<p><a href="product-development.php" target="_blank" class="btn btn-primary special">Our Technology</a></p>
    			<?php echo get_the_post_thumbnail(); ?>
    					<?php
    						$new_query = new WP_Query('category_name=apd-tech' );
    							while ( $new_query->have_posts() ) : $new_query->the_post();
    					?>
    						<ul>
    							<li>
    								<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
    									<?php the_excerpt(); ?>
    									<hr>
    							</li>
    						</ul>
    					<?php
    						endwhile;
    					?>
    			</div><!-- end class div -->
    
    			<div class="col-md-3 col-sm-12 col-xs-12">
    			<p><a href="product-development.php" target="_blank" class="btn btn-primary special">Schedule a demo</a></p>
    				<?php echo get_the_post_thumbnail(); ?>
    					<?php
    						$new_query = new WP_Query('category_name=demo' );
    							while ( $new_query->have_posts() ) : $new_query->the_post();
    					?>
    						<ul>
    							<li>
    								<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
    									<?php the_excerpt(); ?>
    									<hr>
    							</li>
    						</ul>
    					<?php
    						endwhile;
    					?>
    
    			</div><!-- end class div -->
    
    			<div class="col-md-3 col-sm-12 col-xs-12">
    			<p><a href="product-development.php" target="_blank" class="btn btn-primary special">Become a dealer</a></p>
    				<?php echo get_the_post_thumbnail(); ?>
    					<?php
    						$new_query = new WP_Query('category_name=dealers' );
    							while ( $new_query->have_posts() ) : $new_query->the_post();
    					?>
    						<ul>
    							<li>
    								<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
    									<?php the_excerpt(); ?>
    									<hr>
    							</li>
    						</ul>
    					<?php
    						endwhile;
    					?>
    			</div><!-- end class div -->

    thank you
    D

Viewing 1 replies (of 1 total)
  • The get_post_thumbnail() function needs to be after this line:

    while ( $new_query->have_posts() ) : $new_query->the_post();

    Otherwise, it doesn’t know what post thumbnail to get.

Viewing 1 replies (of 1 total)
  • The topic ‘post images are off by a post. Show wrong image’ is closed to new replies.