WordPress: How to Setup A Default Featured Image

A quick tip to setup a site-wide default featured image/thumbnail in WordPress:

function wp_default_featured_img( $html ) {
    // If there is no post thumbnail, return a default image
    if ( '' == $html ) {
        return '<img src="' . get_template_directory_uri() . '/images/default-thumbnail.png" width="150px" height="150px" class="image-class-name" />';
    // Else, return the post thumbnail
    return $html;
add_filter( 'post_thumbnail_html', 'wp_default_featured_img' );

Simply add the above to your functions.php file and make sure the default-thumbnail.png file exists in your images directory and you’re done!

Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358