Here’s a simple php code for WordPress that gets the Featured Image from a parent post and displays it on a child page.

I had this come up recently for someone who was creating an online guide, so the parent post was the primary topic, and they wanted to easily make all sub posts have the same header without having to do it themselves.

I also added the conditional functionality to look for the post thumbnail for the child post first – so that you could overwrite it if you wanted.

This also uses ‘global $post;’ as it was used outside the loop – you should be able to remove that if you’re using it in the loop.

global $post;
if ( has_post_thumbnail() ) { //check for current post thumbnail
   echo get_the_post_thumbnail( $post_id, 'full' ); //show current post thumbnail if it exists
} elseif( has_post_thumbnail( $post->post_parent ) ) { //get parent post thumbnail if it exists
    echo get_the_post_thumbnail( $post->post_parent, 'full' );

Leave a Comment

Your email address will not be published. Required fields are marked *