Last Updated: February 25, 2016
·
1.078K
· rajeshkhatri13

Featured image as header image or post image

add below in function file


addthemesupport( 'post-thumbnails' );
setpostthumbnail_size( 624, 9999 ); // will set image width 624px and Unlimited height, soft crop
</code></pre>

add below in your template file


<?php
if ( haspostthumbnail() ) {
    // the current post has a thumbnail
    thepostthumbnail();
} else {?>
       <img src="<?php echo gettemplatedirectory_uri(); ?>/images/place-hoder-img.jpg" class="">
<?php
}
?>
</code></pre>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#wordpress
Did you know?

WordPress sites collect scripts from themes, plugins, and tag managers. A compromised plugin update can add a skimmer to every page without a change in your own templates.

Security insights from Cside