You can call above “get_first_image” function anywhere in your post loop. I loop you need to just copy paste the following lines
to print the first image of post body.
4 thoughts on “get first image thumbnail from wordpress post”
Thanks for this post, i’m unable to get it working though. After trying several tutorials on using the first post image for thumbnail. This one just doesn’t display anything at all, no errors, but no image.
I added the line to the loop, no idea why it’s not showing anything though >.<
I’m unable to get this to display the thumbnail at all, I’m sure I’ve added it properly. I’ve added thumbnail support and after doing that it displays the same image on every post. Any suggestions?
But this function doesn’t save the image in the database in defined size, it just scales down the image size every time a page is loaded. and this causes to lower page loads.
Can you make it to save the image in that defined sizes and call the function.
Thanks for this post, i’m unable to get it working though. After trying several tutorials on using the first post image for thumbnail. This one just doesn’t display anything at all, no errors, but no image.
I added the line to the loop, no idea why it’s not showing anything though >.<
I’m unable to get this to display the thumbnail at all, I’m sure I’ve added it properly. I’ve added thumbnail support and after doing that it displays the same image on every post. Any suggestions?
that is depends on which wordpress theme you are using. you just need to add the code in index.php file and functions.php file.
Hi
I love the post. and used it in my Website.
But this function doesn’t save the image in the database in defined size, it just scales down the image size every time a page is loaded. and this causes to lower page loads.
Can you make it to save the image in that defined sizes and call the function.
If you can. It would be of great help.