Re-implemented parent post featured inheritance
authorLaury GvR <laury@gaslightmedia.com>
Tue, 9 Feb 2016 20:46:43 +0000 (15:46 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 9 Feb 2016 20:46:43 +0000 (15:46 -0500)
functions.php

index 092d849..d101bb2 100644 (file)
@@ -100,7 +100,14 @@ function glm_site_scripts()
 //    echo '</div>';
 //}
 function glm_get_featured() {
-    if (has_post_thumbnail()) {
+    global $post;
+    $post_id = $post->ID;
+    // inherit featured image from parent pages
+    if ( $post->post_parent && !has_post_thumbnail($post->ID)){
+        $post_id = $post->post_parent;
+    }
+
+    if (has_post_thumbnail($post_id) && (!(is_home()) ) && (!(is_single())) && (!(is_archive())) && (!(is_search()))) {
         $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full");
         $imageUrl = '<div class="featured-image" style="background: url(\''.$image_data[0].'\') no-repeat scroll 0px 0px / cover;;"></div>';
     } else {