WordPress Post’s Attached Images Not Showing Up Correctly on Custom front-page.php

On my static front page I have created, I query the WordPress Loop to only show the two most recent blog posts. For some reason, it started displaying two instances of the attached image for each post. Here is what it looks like:



I have no idea why it is outputting two of the attached images for each.

Read More

Here is the code for this specific part of front-page.php:

<div class="row">
    <?php $latest = new WP_Query('showposts=2'); ?>
    <?php while( $latest->have_posts() ) : $latest->the_post(); ?>

    <a href='<?php echo get_permalink(); ?>'>
    <div class="col-md-6 blog-wrap">

    <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?>
        <div class="home-featured-img" style="background: url(<?php echo $src[0];?>);"></div>

        <div class="excerpt-home">
        <?php get_template_part( 'content', get_post_format() ); ?>
        </div>
    </div></a>
    <?php endwhile; ?>

</div>

I have a feeling that the problem occurs when I call:

If you need any other code snippets from my custom theme, please let me know.

I only want for the post to display the image from this (which is the top picture):

<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?>
<div class="home-featured-img" style="background: url(<?php echo $src[0];?>);"></div>

Any and all suggestions are greatly appreciated.

Related posts

1 comment

  1. you can remove any code like that

    <?php
            // Post thumbnail.
            twentyfifteen_post_thumbnail();
    ?>
    

    Explanation…
    that file display the second image – the title – the meta
    you need to edit it to remove the code that display the image 🙂 thats it.

Comments are closed.