$post->ID
would be correct but does not accurately apply to archive type views in this specific case such as a blog index.php and/or other similar template pages such as a category.php, tag.php, archive.php, etc.
You would need to write a more specific query to identify the first published post(?) and use its ID to designate the “featured image” for the blog index header (if I am understanding your idea here correctly).
As you noted this works on page, I would also suspect your current code idea would work in single views of your posts, too.
~ Cais.
]]>-Burt
]]><?php if(is_home()) {
$img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full');
$featured_image = $img[0];
}?>
It looks like it gets the ID of the page you set under “Reading Settings.” I haven’t tested yet, but looks promising. I assume I would set the condition based on is_page(‘blog’) instead of home?
]]>For the background “Featured Image” on the Blog home page.
<?php
if (is_home()) {
$hero = wp_get_attachment_image_url( get_post_thumbnail_id(get_option('page_for_posts')), 'full' );
} else {
$hero = wp_get_attachment_image_url( get_post_thumbnail_id($post->ID), 'full' );
}
?>
For the custom fields on the Blog home page.
<?php
if (is_home()) {
the_field('header_headline', get_option('page_for_posts'));
} else {
the_field('header_headline');
}
?>
Could I have done this differently? Is there a standard? Thanks!
]]>