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.
The page I need help with: [log in to see the link]
The topic ‘Problem after adding get thumbnail code to archive.php’ is closed to new replies.