Title: Problem after adding get thumbnail code to archive.php
Last modified: January 17, 2020

---

# Problem after adding get thumbnail code to archive.php

 *  Resolved [anoctave](https://wordpress.org/support/users/anoctave/)
 * (@anoctave)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/)
 * My archive page was not showing the featured images from the post. I located 
   code in a front page section that showed current blog post teasers that did show
   the featured image. In the front page section code, the snippet appeared in a
   while .. do section where individual posts were called.
 *     ```
       <?php if ( has_post_thumbnail($post->ID) ): ?>
       									<a class="item-featured-image" href="<?php esc_url( the_permalink() ); ?>"><?php echo get_the_post_thumbnail($post->ID, 'latte-blogposts'); ?></a>
       								<?php else: ?>
       									<a class="item-featured-image" href="<?php esc_url( the_permalink() ); ?>"><img src="<?php echo get_template_directory_uri().'/assets/images/287x230.png'; ?>"/></a>
       								<?php endif; ?>
       ```
   
 * I placed a copy of the archive.php of my parent theme into my child theme. I 
   placed the above code after the code “If have posts, while have posts, get post”,
   nestled with a div…/div followed by the remainder of the get post, i.e.the printing
   of the title, subtitle and the excerpt.
 * What happened: on the first page of the archives the featured image was shown
   for all the posts. However,the first featured image appeared right under the 
   header with no space -and the remaining posts on the page are a little crammed.
   No amount of inline styling changed anything.
 * I would dearly appreciate some help with this.
    -  This topic was modified 6 years, 4 months ago by [anoctave](https://wordpress.org/support/users/anoctave/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-after-adding-get-thumbnail-code-to-archive-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12337731)
 * please post the full code of your edited archive.php
 * there are no featured images visible in your linked archive page right now which
   makes checking the formatting difficult.
 * also please consider to ask the developer of your commercial theme for help.
 *  Thread Starter [anoctave](https://wordpress.org/support/users/anoctave/)
 * (@anoctave)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12337806)
 * sorry. Here it is:
 *     ```
       <?php get_header(); ?>
       archive.php
       1
       <header class="archive-header">
       <div class="cover-container row">
       <div class="inner cover col-md-12">
       <h1 class="cover-heading"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php
       bloginfo( 'name' ); ?></a></h1>
       <p class="lead"><?php bloginfo( 'description' ); ?></p>
       </div>
       </div>
       </header>
       <div class="container blog">
       <div class="row">
       <?php
       $theme_layout = get_theme_mod( 'latte_blog_sidebar', 'full' );
       if ($theme_layout=="left") :
       get_sidebar();
       endif;
       ?>
       <?php if ($theme_layout=="full") : ?>
       <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
       <?php else: ?>
       <div class="col-lg-8 col-md-8">
       <?php endif; ?>
       <?php if ( have_posts() ) : ?>
       <?php while ( have_posts() ) : the_post(); ?>
       <div class="thumbs">
       <?php if ( has_post_thumbnail($post->ID) ): ?>
       <a class="item-featured-image" style="padding-top,padding-bottom:50px;"
       href="<?php esc_url( the_permalink() ); ?>"><?php echo
       get_the_post_thumbnail($post->ID, 'latte-blogposts'); ?></a>
       <?php else: ?>
       <a class="item-featured-image" style="padding-top,padding-bottom:50px;"
       href="<?php esc_url( the_permalink() ); ?>"><img src="<?php echo
       get_template_directory_uri().'/assets/images/287x230.png'; ?>"/></a>
       <?php endif; ?>
       </div>
       <?php get_template_part( 'content', ( post_type_supports( get_post_type(),
       'post-formats' ) ? get_post_format() : get_post_type() ) ); ?>
       <?php endwhile; ?>
       <ul class="pager">
       <?php if( get_previous_posts_link() ) : ?>
       <li class="previous"><?php previous_posts_link(); ?></li>
       <?php endif; ?>
       <?php if( get_next_posts_link() ) : ?>
       <li class="next"><?php next_posts_link(); ?></li>
       <?php endif; ?>
       </ul>
       <?php else : ?>
       <?php get_template_part( 'content', 'none' ); ?>
       <?php endif; ?>
       </div>
       <?php
       if ($theme_layout=="right") :
       get_sidebar();
       endif;
       ?>
       </div>
       </div>
       <?php get_footer(); ?>
       ```
   
 * Thank you for taking a look at it. Sorry it’s so long.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12338278)
 * > on the first page of the archives the featured image was shown for all the 
   > posts.
 * the code seems to be ok, confirmed by the fact that it showed all the featured
   images.
 * > However,the first featured image appeared right under the header with no space-
   > and the remaining posts on the page are a little crammed.
 * we need a live link with the featured images to be able to say anything about
   that problem.
 * as the `<div class="thumbs">` part of the theme or your creation?
    it might be
   inserted too early, i.e. before the container holding the content.
 * possibly, the featured image code needs to be inserted into **content.php** to
   preserve the html structure for proper formatting.
 * to get more theme related support, please contact the developer of your commercial
   theme for help.
 *  Thread Starter [anoctave](https://wordpress.org/support/users/anoctave/)
 * (@anoctave)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12339567)
 * I have put the edited archive.php back. Now the thumbnails are showing on all
   archive pages. The only problem I have is the top post on each archive page is
   abutting the header.
 * (What I am doing with this site is recreating the original site, which is still
   active. In this development site, I’m trying to change things that I wasn’t pleased
   with on the original site. When I get everything done, I am moving the domain
   name over to the host where I’m developing.)
 * I looked at content.php and it does indeed have code for the thumbnail, but obviously
   the archive page was not using it. I don’t know php well enough to write my own,
   but looking at the way it’s calling and outputting the content, it doesn’t look
   like as if there is anyway to put the code I added there. If there is a way to
   call the thumbnail and the excerpt that might do the trick but, as I say, I don’t
   know php or wordpress well enough.
 * Thank you for looking at this. With the changes I’ve been trying to make, I hope
   I will be well-enough prepared for a WordPress Camp I’m going to in May.
 *  Thread Starter [anoctave](https://wordpress.org/support/users/anoctave/)
 * (@anoctave)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12339834)
 * I’ve got it fixed. I was trying to do it simply by my own coding, I decided to
   run it through the SiteOrigin CSS editor, which selects the right element to 
   add things like padding.
 * I was also able to get the name of the archive as the archive page title.
 * So all is good. Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem after adding get thumbnail code to archive.php’ is closed to 
new replies.

## Tags

 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [anoctave](https://wordpress.org/support/users/anoctave/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/problem-after-adding-get-thumbnail-code-to-archive-php/#post-12339834)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
