Title: Dynamically Change Header Image?
Last modified: October 22, 2017

---

# Dynamically Change Header Image?

 *  [Glennf](https://wordpress.org/support/users/glennf/)
 * (@glennf)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/dynamically-change-header-image/)
 * Is it possible to dynamically change the header image based on the page that 
   is selected by the viewer?

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

 *  Theme Author [ronangelo](https://wordpress.org/support/users/ronangelo/)
 * (@ronangelo)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/dynamically-change-header-image/#post-9618149)
 * Sure. If for example you want the header image to be the post’s Featured Image,
   
   something like this should work.
 *     ```
       add_action( 'wp_head', 'add_header_bg_css', 999 );
   
       function add_header_bg_css() {
   
       	if ( !has_post_thumbnail() ) return;
   
       	$img = get_the_post_thumbnail( get_the_ID() );
   
       	echo '<style>#header { background-image: url(\'' . $img . '\'); }</style>';
       }
       ```
   
 *  Thread Starter [Glennf](https://wordpress.org/support/users/glennf/)
 * (@glennf)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/dynamically-change-header-image/#post-9619532)
 * Thanks so much. What code would be used to change the header image when a person
   navigates to a certain wordpress page?
 * What files do you add that action and function to?
 * -Glenn

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

The topic ‘Dynamically Change Header Image?’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/frontier/1.3.3/screenshot.png)
 * Frontier
 * [Support Threads](https://wordpress.org/support/theme/frontier/)
 * [Active Topics](https://wordpress.org/support/theme/frontier/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/frontier/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/frontier/reviews/)

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Glennf](https://wordpress.org/support/users/glennf/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/dynamically-change-header-image/#post-9619532)
 * Status: not resolved