From: Anthony Talarico Date: Fri, 16 Dec 2016 17:08:06 +0000 (-0500) Subject: adding checks for thumbnail image and post excerpt before trying X-Git-Tag: v1.0.0^2~41 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=537562382ec52fc2f8f01d53d10ce854b17dff8f;p=WP-Themes%2Fmackinawareavb.git adding checks for thumbnail image and post excerpt before trying to assign the values to an array for the interactive day trips dropdown map --- diff --git a/parts/interactive-map.php b/parts/interactive-map.php index a6cc6e0..e6b0660 100644 --- a/parts/interactive-map.php +++ b/parts/interactive-map.php @@ -37,9 +37,19 @@ foreach ($nav_posts as $p){ $sites[$p->ID]['url'] = get_permalink( $p->ID ); $sites[$p->ID]['title'] = get_the_title($p->ID ); - $image = wp_get_attachment_image_src( get_post_thumbnail_id($p->ID), 'map-image'); - $sites[$p->ID]['image'] = $image[0]; - $sites[$p->ID]['excerpt'] = get_the_excerpt( $p->ID ); + if (has_post_thumbnail($p->ID)){ + $image = wp_get_attachment_image_src( get_post_thumbnail_id($p->ID), 'map-image'); + $sites[$p->ID]['image'] = $image[0]; + } else { + $image = get_template_directory_uri() . '/assets/silver-image.jpg'; + $sites[$p->ID]['image'] = $image; + } + + if (has_excerpt($p->ID)){ + $sites[$p->ID]['excerpt'] = get_the_excerpt( $p->ID ); + } else { + $sites[$p->ID]['excerpt'] = " "; + } } $js_sites = json_encode($sites); ?>