Posts not displaying without featured images
-
I’m having an issue; when one of my posts does not have a featured image non of the post displays (text included).
This started when I added some code to display the captions for featured images.
This is the original code which resolves the missing posts issue, but does not display the image captions.
<?php if ( '' != get_the_post_thumbnail() && ! post_password_required() && ! get_theme_mod('hide_singlethumb') ) : ?> <div class="entry-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'zuki' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail(); ?></a> </div>This is the code I replaced the above code with to display the image captions, but it does not display posts if no featured image is set.
<?php $get_description = get_post(get_post_thumbnail_id())->post_excerpt; the_post_thumbnail(); if(!empty($get_description)){//If description is not empty show the div echo '<span class="caption_arrow"></span><br><div class="featured_caption">' . $get_description . '</div>'; } ?>I’m working on this site locally, so I can’t provide a url.
What am I missing here? Can I combine the two code snippets in someway?Any advice or help would be much appreciated.
Thanks,
Zack
The topic ‘Posts not displaying without featured images’ is closed to new replies.