0

I was searching how I can get the featured images of the parent also on the child pages, without uploading it also for the childs.

How can this solve?

1

You can use get_the_post_thumbnail() and pass the ID of the parent instead:

if ( $post->post_parent )
    $post_id = $post->post_parent;
else
    $post_id = $post->ID;

if ( $thumbnail = get_the_post_thumbnail( $post_id, 'post-thumbnail' ) ) {
    echo $thumbnail;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.