SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    794
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    incorrect image display on post. Shows image from the previous post.

    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?

    Code:
    <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

  2. #2
    SitePoint Evangelist WebMachine's Avatar
    Join Date
    Jun 2007
    Location
    Ontario, Canada
    Posts
    426
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just a shot in the dark - but you have get_the_postthumbnail() before you query the post. How does WordPress know what thumbnail you want? Then after your first wp_Query you have a get_the_postthumbnail() before your second one, but I think it would be referring to the first wp_Query.

    Would it work if you put your get_the_postthumbnail()'s right after each
    Code:
    $new_query = new WP_Query('category_name=apd-tech' );
    							while ( $new_query->have_posts() ) : $new_query->the_post();
    so that it is in the correct loop?

  3. #3
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    794
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    WebMachine Thank you! you were right that did it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •