# How to get and echo the Header Image

**URL:** <https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698>\
**Category:** Travelify\
**Created:** [May 19, 2014, 2:17pm UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698 "2014-05-19T14:17:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ardanny](https://colorlibsupport.com/letter_avatar_proxy/v4/letter/a/8e8cbc/32.png) [@ardanny](https://colorlibsupport.com/u/ardanny)\
**Post date:** [May 19, 2014, 2:17pm UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/1 "2014-05-19T14:17:19Z")

</div>

Hey Aigars,  
the reason why I’m bothering you again is to know if it’s possible to get the header image that I’ve specified for every given page and echo it under the page title. The reason why I’m asking these odd placement questions is that the website which I’m constructing is required to be “transparent” without the common horizontal header.  
Here’s a page example: “Ολυμπιακή Παιδεία” is the title and i want the image to stretch right under it.  
[http://www.olympiacamp.gr/olympic-trainship/](http://www.olympiacamp.gr/olympic-trainship/)  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![aigars-silkalns](https://colorlibsupport.com/user_avatar/colorlibsupport.com/aigars-silkalns/32/13469_2.png) [@aigars-silkalns](https://colorlibsupport.com/u/aigars-silkalns)\
**Post date:** [May 19, 2014, 2:31pm UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/2 "2014-05-19T14:31:39Z")

</div>

This is the code used to output featured image (I guess you are mixing featured images with WordPress custom header, am I right?)

```auto
			<?php
			if( has_post_thumbnail() ) {
				$image = '';
	     		$title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
	     		$image .= '<figure class="post-featured-image">';
	  			$image .= '<a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">';
	  			$image .= get_the_post_thumbnail( $post->ID, 'featured', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ) ) ).'</a>';
	  			$image .= '</figure>';

	  			echo $image;
	  		}
  			?>

```

Add this code to `content-extensions.php` somewhere in `travelify_theloop_for_page` function depending where you want featured image to be displayed.

Let me know if this is what you wee looking for.

---

<div class="post-metadata">

**Author:** ![ardanny](https://colorlibsupport.com/letter_avatar_proxy/v4/letter/a/8e8cbc/32.png) [@ardanny](https://colorlibsupport.com/u/ardanny)\
**Post date:** [May 19, 2014, 2:43pm UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/3 "2014-05-19T14:43:16Z")

</div>

Well, I was referring to the Header Image field which resides in the administration panel but this seems to be working fine too and will do the trick.  
Thanks a lot again!

---

<div class="post-metadata">

**Author:** ![nikolay](https://colorlibsupport.com/user_avatar/colorlibsupport.com/nikolay/32/2420_2.png) [@nikolay](https://colorlibsupport.com/u/nikolay)\
**Post date:** [July 11, 2014, 1:43am UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/4 "2014-07-11T01:43:59Z")

</div>

Hello, Aigars,  
is it possible to specify different header images for different site categories? i.e.: [mydomain.com/CATEGORY/pagename](http://mydomain.com/CATEGORY/pagename) - where each category has its own header image.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![aigars-silkalns](https://colorlibsupport.com/user_avatar/colorlibsupport.com/aigars-silkalns/32/13469_2.png) [@aigars-silkalns](https://colorlibsupport.com/u/aigars-silkalns)\
**Post date:** [July 11, 2014, 7:01am UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/5 "2014-07-11T07:01:26Z")

</div>

You can code your own solution by using [\<?php is\_category( $category ); ?\>](http://codex.wordpress.org/Function_Reference/is_category) function (Advanced). You can read more about it on WordPress documentation.

or just use some plugin like [WP Display Header](http://wordpress.org/plugins/wp-display-header/).

---

<div class="post-metadata">

**Author:** ![nikolay](https://colorlibsupport.com/user_avatar/colorlibsupport.com/nikolay/32/2420_2.png) [@nikolay](https://colorlibsupport.com/u/nikolay)\
**Post date:** [July 11, 2014, 6:22pm UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/6 "2014-07-11T18:22:01Z")

</div>

Thanks, it works! I rated you theme 5 stars on [WordPress.org](http://WordPress.org) in recognition!

---

<div class="post-metadata">

**Author:** ![aigars-silkalns](https://colorlibsupport.com/user_avatar/colorlibsupport.com/aigars-silkalns/32/13469_2.png) [@aigars-silkalns](https://colorlibsupport.com/u/aigars-silkalns)\
**Post date:** [July 14, 2014, 9:58am UTC](https://colorlibsupport.com/t/how-to-get-and-echo-the-header-image/5698/7 "2014-07-14T09:58:53Z")

</div>

@Nikolay

Thank you for your feedback! I really appreciate it!
