Created
August 4, 2012 23:17
-
-
Save hansspiess/3260545 to your computer and use it in GitHub Desktop.
Wordpress: Displaying Article Thumbnail of parent page on Child Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
if ( is_page() ) { | |
/* Get an array of Ancestors and Parents if they exist */ | |
$parents = get_post_ancestors( $post->ID ); | |
/* Get the top Level page->ID count base 1, array base 0 so -1 */ | |
$id = ($parents) ? $parents[count($parents)-1]: $post->ID; | |
echo get_the_post_thumbnail( $id, 'full' ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment