Featured images duplicating and replacing next image

Took over a project, and one of the errors is the featured images (and certain others rendered in a similar way) are duplicating themselves and replacing the next image thumbnail.

      a href="?php echo get_permalink(); ?" class="snack__thumb snack__thumb--featured" style="background-image:url('?php echo get_the_post_thumbnail_url( $post-ID, 'medium' ); ?');"
?php
  if (has_category('whitepaper')) { ?
    div class="snack__banner"spanwhitepaper/span/div
  ?php 
  } 
?

I've read that not ending a loop with something like wp_reset_postdata(); can cause this type of error however I haven't been able to get it solved.

Relevant plugins installed are
NS Featured Posts Ajax-Load-More (Error happening within Load-more field)

This happens on the home page as well in this loop

?php while ($latest_posts-have_posts()) : ?
  div class="col-md-4"
    ?php 
      $latest_posts-the_post();
      include(locate_template('loop-templates/content-snack.php'));
    ?
  /div
  ?php endwhile; wp_reset_query(); ?
  /div
  ?php 
    if ($latest_posts-max_num_pages  1) {
      echo(do_shortcode('[ajax_load_more id="posts-loader" container_type="div" post_type="post" posts_per_page="6" post_format="standard" pause="true" post__not_in="'.implode(",",$special_ids).'" scroll="false" transition_container_classes="row" button_label="See more posts"]'));
    }
  ?

Topic featured-post php images Wordpress

Category Web


This was due to having an inline <?php $post = get_post()?> After moving this out and making it global, images stopped duplicating.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.