checking to see if the page has an excerpt before trying to access it
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 16 Dec 2016 14:00:15 +0000 (09:00 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 16 Dec 2016 14:00:15 +0000 (09:00 -0500)
to prevent getting the page content instead

sections/top-bar.php

index a929638..4ca2206 100644 (file)
@@ -34,7 +34,12 @@ foreach($post_data as $pd=>$value){
         $image = false;
     }
     $image = wp_get_attachment_image_src( get_post_thumbnail_id( $value->ID ), array(300,250) );
-    $dropdown[$value->ID]['excerpt'] = get_the_excerpt($value->ID);
+    if (has_excerpt($value->ID) ){
+        $dropdown[$value->ID]['excerpt'] = get_the_excerpt($value->ID);
+    } else {
+        $dropdown[$value->ID]['excerpt'] = " ";
+    }
+    
     $dropdown[$value->ID]['menu'] = $pd;
     
 }