On my custom wordpress theme, I am using the featured image thumbnail for all of my pages to be the header of the page.
I've created a page called "blog" and using it as the archive ( via settings -> reading -> selecting "blog" for post display page ) reading, but when I try to use the featured image of that page, it tries to display ALL of the featured images from the blogs, not just my one archive page how I want.
I'm pretty sure it's a matter of altering the if statement to only show the thumb of the archive page, but I'm not sure how.
Here is my code on index.php
<?php get_header(); ?>
<section>
<?php if ( have_posts()) : while ( have_posts() ) : the_post(); ?>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<a class="page-thumb" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<div class="page-thumb" style="background-image:url('<?php echo $url ?>');"></div>
</a>
<?php endif; ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="page-h1 animate-reveal">
<?php the_title(); ?>
</h1>
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else : ?>
<!-- article -->
<!-- /article -->
<?php endif; ?>
</section>
<main role="main" aria-label="Content" class="page-bg page-margin">
<!-- section -->
<section>
<h1 class="archive-h1">News</h1>
<?php get_template_part( 'loop' ); ?>
<?php get_template_part( 'pagination' ); ?>
</section>
<!-- /section -->
</main>
<?php get_footer(); ?>
EDITS using answer #1
complete index.php file below
<?php get_header(); ?>
<main role="main" aria-label="Content" class="page-bg page-margin">
<!-- section -->
<section>
<?php
$page_for_posts = get_option( 'page_for_posts' );
if ($page_for_posts && has_post_thumbnail($page_for_posts)) {
$thumb_id = get_post_thumbnail_id( $page_for_posts);
$url = wp_get_attachment_url( $thumb_id );
if ( have_posts()) : while ( have_posts() ) : the_post(); ?>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<a class="page-thumb" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<div class="page-thumb" style="background-image:url('<?php echo $url ?>');"></div>
</a>
<?php endif; ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="page-h1 animate-reveal">
<?php the_title(); ?>
</h1>
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else : ?>
<!-- article -->
<!-- /article -->
<?php endif; ?>
<?php } ?>
<h1 class="archive-h1">News</h1>
<?php get_template_part( 'loop' ); ?>
<?php get_template_part( 'pagination' ); ?>
</section>
<!-- /section -->
</main>
<?php get_footer(); ?>