Skip to content

Instantly share code, notes, and snippets.

@hansspiess
Created August 4, 2012 23:17
Show Gist options
  • Save hansspiess/3260545 to your computer and use it in GitHub Desktop.
Save hansspiess/3260545 to your computer and use it in GitHub Desktop.
Wordpress: Displaying Article Thumbnail of parent page on Child Page
<?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