Day 7: Enabling Thumbnails in Featured Posts in WordPress
WordPress, I love what you’ve done with yourself – especially your ability to include images in featured posts. In the past, I’ve always done this through custom fields (which was quite messy in my opinion), but thankfully I will have to do that no more!
To enable featured posts, add this snippet to functions.php
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
And this to your loop
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
Also, if you have specific dimensions in mind for your post thumbnail, add this to functions.php
set_post_thumbnail_size( width, height, true );
Want to learn more about Post Thumbnails? Visit the WordPress Codex.