Last updated on February 10, 2018
In this post, I would like to show you how to enable WordPress post thumbnails on your WordPress theme. Post thumbnails are pretty useful and very easy to activate.To enable post thumbnails simply paste the following code into your current theme’s functions.php file.
// add post thumbnail support add_theme_support('post-thumbnail');
How to Display
Now to Display Post Thumbnail in views, past the fallowing code.
// check for thumbnail if(has_post_thumbnail()) { the_post_thumbnail(); }
Reference URLs
- add_theme_support($feature, $arguments): Allows a theme or plugin to register support of a certain theme feature.
- has_post_thumbnail():Check if post has an image attached.
- the_post_thumbnail ( string|array $size = ‘post-thumbnail’, string|array $attr = ” ) Display Post Thumbnail.