HI I am using wordpress v3.03 and I am wondering how do I get featured images for the post in my theme
Currently I am using
get_the_post_thumbnail( $post->ID, 'post-thumbnail')
and it worked fine with 1 images, but when i kept add new images the above code always retrieve the first image i attached to the post instead of the image i set as “featured”
any help will be appreciated
In you’re theme functions.php file add
Then in wp-admin when you edit a post you should have a featured image box where you can set 1 featured image . Then in the loop you can use the following functions :
Update
After you added post-thumbnails theme support , you need to set the featured image using the “featured image” box on the right sidebar on wp-admin/post.php page . It’s right under the “post tags” box . Then outside the loop you can use get_the_post_thumbnail() function to retrive that image . If you didn’t set any featured image for the post it will fetch the last image you inserted in that post .
One other way to set the featured image would be ( after you added post-thumbnail theme support ) , is when you insert an image into the post you will have a “set featured image” after you uploaded ( on the modal that let’s you select image alignment ) . Then the image should be visible on the right sidebar “featured image” box .