Hi.
The problem with your code is that you can't access post information while in the home page. The way WP works is that, when you are in the home page, you are not inside a post, so the post data is not accessible.
What you could do is have one header for your home page and one for your posts. Something like this in your header.php file would work:
<?php
if( is_home() ) {
$header = '<p>We are Home</p>';
} else if( is_single() ) {
$header = '<img src="path/to/image" alt="image" />'
} else {
$header = '<p>Default Header</p>';
}
echo $header;
?>
If you only need a custom header for your home page only and the same header in the rest of the site, simply remove the else ifpart of the code:
<?php
if( is_home() ) {
$header = '<p>We are Home</p>';
} else {
$header = '<p>Default Header</p>';
}
echo $header;
?>
Another simpler alternative for this last version would be:
<?php
$header = ( is_home() ) ? '<p>We are Home</p>' : '<p>Default Header</p>';
echo $header;