Hi Friends, Some days ago I changed my site theme and tats why to give it good look I decided to use featured image for post feature for every post, In which we can select featured image for every post while writing new post from right part. I am web developer and I have used this functionality in many other project which was enabled by default, But when I changed my theme I found that featured image is not supported by this theme or feature image functionality is not available at right side in my admin while writing/editing post. So I have searched about it and finally found solution for it which was very easy.
– First, in the theme’s functions.php file, declare that your theme supports this feature by writing below code. This will enable the UI in the WP Admin.
add_theme_support( 'post-thumbnails');
That will enable Post Thumbnail UI for both Post and Page content types. If you’d only like to add it to one, you can do it like this :
add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages
By this way you can enable featured image feature for post and page or for only page or for only post in your WordPress blog. Now one more thing that how we can show this featured image on out site. So there is one function by which you can show this featured image on your site which is given below :
<?php the_post_thumbnail( 'thumbnail' ); ?>;
Please write this function inside while loop. Wherever you write this function it will show featured image for that post. Please let me know if you are not clear in this or having problem in this I will try to solve it.