Iâve got a WordPress site and have added the following code to the Single.php file, which means if I publish a blog post without selecting a âFeatured Imageâ, it will display a default âFeatuered Imageâ instead (tellymedia-temporary-image.jpg).
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/branding/tellymedia-temporary-image.jpg" alt="<?php the_title(); ?>" />
This works fine on the actual page displaying the individual blog post (which shows the default image), but Iâm also using the following code in my Functions.php file, to display a âFeatured Imageâ thumbnail for each post in the Sidebar:
<a href="<?php the_permalink(); ?>"><span class="widget-listing-thumbnail"><?php the_post_thumbnail(); ?></span><?php get_the_title() ? the_title()+the_subtitle('<span class="widget-subtitle">', '</span class="widget-subtitle">') : the_ID(); ?></a>
While this works for all other posts it doesnât work for any where I havenât selected a âFeatued Imageâ. Is there a way to tweak the code in my Functions.php file please, so it will also display a thumbnail of the default âFeatuered Imageâ in the Sidebar for posts where I havenât selected one please?
Thanks!
try this one.