Title: Bug with post_thumbnail
Last modified: August 20, 2016

---

# Bug with post_thumbnail

 *  [Noisie](https://wordpress.org/support/users/noisie/)
 * (@noisie)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/bug-with-post_thumbnail/)
 * For a project I want a dynamic header image on most pages. To do this I wanted
   to solve it with a thumbnail on each page.php. The problem I have is that archive
   and single pages are causing bugs because it also loads extra post_thumbnails.
   The code I have atm is:
 * _<?php if (is\_home()) { ?>
    <div id=”myCarousel” class=”carousel slide”> <!–
   Carousel items not relevant –> </div> <?php } elseif (is\_archive()) { ?> <img
   src=”<?php bloginfo(‘template\_directory’);?>/assets/img/archive-img.jpg” alt
   =”” /> <?php } elseif (is\_single()) { ?> <img src=”<?php bloginfo(‘template\
   _directory’);?>/assets/img/single-img.jpg” alt=”” /> <?php } elseif (has\_post\
   _thumbnail()) { ?> <?php the\_post\_thumbnail(‘header-thumbnail’); ?> <?php }
   else { ?> <img src=”<?php bloginfo(‘template\_directory’);?>/assets/img/custom-
   img.jpg” alt=”” /> <?php } ?>
 * Strange thing is it works perfect at my archive pages (It loads the image I called
   but on single pages it still loads the single post thumbnail instead of the header
   thumbnail.
 * I marked the header thumbnail with: the_post_thumbnail(‘header-thumbnail’) and
   single post thumbnail with the_post_thumbnail(‘single-thumbnail’) with the correct
   markup in my functions.php.
 * Anyone got a clue what I am doing wrong? I know the php can be shorter but its
   just a project to test what is possible so I can optimize it later on.

The topic ‘Bug with post_thumbnail’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Noisie](https://wordpress.org/support/users/noisie/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/bug-with-post_thumbnail/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
