Featured image for news page

If I am reading your question correctly, the problem is that when you set a page so that it has a an archive Loop on it $wp_query and the $posts variable are set to for the index Loop and not for the page the are on. To get information about that page you need get_queried_object. Two lines will show your featured image.

$obj = get_queried_object();
echo get_the_post_thumbnail($obj->ID);

One line if your PHP is recent enough

echo get_the_post_thumbnail(get_queried_object()->ID);

Obviously you will want to do something a bit more complicated to check for errors and avoid notices, but basically that is it.

Be careful with get_queried_object. It returns very different information depending on the type of page you are on– index, single, author archive, tab archive, etc.

Leave a Comment