Conditional thumbnail display not working
-
Hi,
I am trying to get post thumbnail out of loop with a default thumbnail image for those posts which don’t have featured image, now issue is either i receive default thumbnail image for all posts OR thumbnail for those posts which have featured image & no thumbnail for posts which don’t have featured image.Is there any way by which i can get conditional thumbnail working. My code is:
<img class="img-circle img-thumbnail" src="<?php if ( function_exists('wp_get_thumb_url')) { echo wp_get_thumb_url($value->ID);} else { echo get_template_directory_uri().'/assets/images/default-user.jpg'; } ?>" alt="<?php echo $value->post_title; ?>">
And
function wp_get_thumb_url($post_ID){ return wp_get_attachment_url( get_post_thumbnail_id( $post_ID ) ); }
Thanks in advance for any help OR suggestions.
- The topic ‘Conditional thumbnail display not working’ is closed to new replies.