This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago .
I have created a theme that uses a featured image on every page.
In settings, I have setup my “Posts Page” to be “news”…how do I get the featured image from “news” to display?
The following will display the id of my posts page:
<?php
$page_for_posts = get_option( 'page_for_posts' );
echo $page_for_posts;
?>
So I was thinking that this would display the featured image for my posts page:
<?php
$page_for_posts = get_option( 'page_for_posts' );
echo get_the_post_thumbnail($page_for_posts, 'large');
?>
But, somehow it doesn’t 🙁 Do I need to add this code in the loop or something?
Any ideas?
Thanks,
Josh
I feel like such an idiot!! I was trouble-shooting this last night and I guess I removed the featured image for the news page…so, of course, the image wasn’t showing up!
I added the featured image and the following code:
<?php if(is_home()) { ?>
<?php
$page_for_posts = get_option( 'page_for_posts' );
echo get_the_post_thumbnail($page_for_posts, 'large');
?>
<?php } ?>
Now, everything works as expected (Note: cross-posted from, and issue resolved in, the wordpress.org support forums.)