You can either use this plugin: http://ww.wp.xz.cn/plugins/default-featured-image/
Or by replacing image hook in your theme with following code:
All you really have to do is open the theme file where you are going to display the post thumbnail, this can be (home.php, single.php, loop.php, index.php, archive.php, etc). Then simply paste the following code within the post loop.
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
Thread Starter
aronk
(@aronk)
Thanks for the fast answer. But I oppened the index.php and inserted the function: (I want to redirect to google per example)
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src=”http://google.com” />
<?php } ?>
But is still not working. What am I doing wrong? Thanks
The default fallback image will only appear if the post doesn’t have a featured image, otherwise the featured image will appear.
Make sure you link to a valid image file as http://google.com is not an image file.
Thread Starter
aronk
(@aronk)
No. I want that my image has an link redirecting to google. I dont want to change every single time to 1-custom link 2-http://www.google.com