I have a page "Blog" and it's set to display latest posts. This page itself has a thumbnail, and I want it to be displayed in header. Every other page/post has same layout and thumbnail shows in header just fine. And I managed to make it somehow work on "Blog" page also.
Here is my code:
<?php global $post;
if ( is_home() ) {
$currentpageid = get_option( 'page_for_posts' );
} else {
$currentpageid = $post->ID;
}
$page_thumb = wp_get_attachment_image_src( get_post_thumbnail_id($currentpageid), 'full' ); ?>
<header <?php if ( has_post_thumbnail() ) { ?> style="background-image: url(<?php echo $page_thumb['0'];?>)"<?php }?>></header>
Now the strange thing is that the "Blog" page's thumbnail shows up in header only if latest post in the loop also has a thumbnail. What could be the reason?
EDIT
well, $currentpageid = get_option( 'page_for_posts' );
actually returns a correct page id in this case, I can echo it anywehere. But when i try to pass it to any function - it doesn't work
$page_thumb = wp_get_attachment_image_src( get_post_thumbnail_id($currentpageid), 'full' );