December 10, 2015
If you’d like to continue using the_post_thumbnail in your theme, but do not want to use a fixed default, use this snippet to inherit images from parent pages.
global $post; if ( has_post_thumbnail() ) { the_post_thumbnail(); } else { echo get_the_post_thumbnail($post->post_parent); }
Update, December 15, 2015
Inherit the_post_thumbnail from ancestor:
global $post; $parents = get_post_ancestors( $post->ID ); /* Get the ID of the 'top most' Page if not return current page ID */ $id = ($parents) ? $parents[count($parents)-1]: $post->ID; if(has_post_thumbnail( $id )) { echo get_the_post_thumbnail( $id, 'full'); }