WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Display WordPress Post Thumbnails with Captions

How to Display WordPress Post Thumbnails with Captions

Last updated on May 1st, 2013 by Editorial Staff
68 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Display WordPress Post Thumbnails with Captions

WordPress has this amazing feature known as Post Thumbnails also referred to as Featured Images. When uploading a post thumbnail, you are asked to add a caption, description, along with other fields, but when you get ready to display it, it only shows the image. In this article, we will share a small trick that will let you display captions or entire image descriptions with your post thumbnail.

First thing first, you need to enable Post Thumbnails in your WordPress Theme. Now, when you upload an image using the media uploader, you will see something like this:

Add an Image

You will need to go ahead and fill all of the information. Now one thing that many folks do not know is that WordPress stores each image as its own post. So the Title of the Image will be the title of the post, Caption will be the excerpt of the post, and Description will be the content of the post. So you can display all of these information when you are displaying your WordPress Thumbnail.

To display your post thumbnail with its caption, simply paste the following code inside the loop:

<?php the_post_thumbnail();
echo get_post(get_post_thumbnail_id())->post_excerpt; ?>

You can obviously style it the way you want to style it.

You can also display entire image description by adding this code inside the post loop:

<?php the_post_thumbnail();
echo get_post(get_post_thumbnail_id())->post_content; ?>

This really simple trick can go long way in styling your next custom WordPress theme.

68 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

27 Comments

Leave a Reply
  1. Anonimus says:
    Jan 11, 2019 at 2:18 pm

    Thanks

    Reply
    • WPBeginner Support says:
      Jan 14, 2019 at 12:54 pm

      You’re welcome :)

      Reply
  2. Zlatev says:
    Aug 24, 2016 at 3:14 am

    Built-in in 4.6 –

    Reply
    • Chris says:
      Aug 30, 2016 at 1:54 pm

      How?

      Reply
  3. Frank says:
    Oct 21, 2014 at 12:43 pm

    no alt text????

    Reply
  4. zaib azhar says:
    May 26, 2014 at 2:48 am

    in which file?

    Reply
  5. Moyen says:
    Feb 6, 2014 at 9:34 am

    Hello,
    I tried to get the featured image by calling the specific post ID and get_post function but everything is okay except featured image. It does not show featured image.

    is there problem to call by post ID and get_post(); ?

    my code?

    // custome template (community)


    post_title; ?>

    post_content; ?>

    Please any idea?

    Reply
    • WPBeginner Support says:
      Feb 6, 2014 at 9:54 pm

      We are sorry we can not see the code. You can put your code in http://pastebin.com/ and then share the link in the comment.

      Reply
  6. Sabir says:
    Jan 17, 2014 at 7:50 am

    This is very great and very helpful. Thank you so much!

    Reply
  7. Trisha says:
    Jan 8, 2014 at 5:52 pm

    Thank you for explaining this! I just needed to add the image captions and spent a lot of time searching for a solution…..I found a lot of other answers on the WP support forum, but none of them explained how featured images are stored……such a simple thing now that I understand.

    Reply
  8. Vali_REK says:
    Nov 1, 2013 at 7:38 pm

    Hello, great post.
    Please explain if I can do that in other website.
    I d like to show article or category from wordpress blog on opencart website.
    Thank you

    Reply
    • WPBeginner Support says:
      Nov 2, 2013 at 3:41 pm

      You can fetch WordPress content into OpenCart website using RSS Feed.

      Reply
  9. Aneas Nemorosus says:
    Oct 9, 2013 at 3:37 pm

    Where can I buy you a coffee????

    Reply
    • Editorial Staff says:
      Oct 9, 2013 at 4:00 pm

      You can send us a donation using the forms here:

      https://www.wpbeginner.com/wpbeginner-needs-your-help/

      Reply
  10. Mike says:
    Sep 3, 2013 at 3:34 pm

    I still don’t know what or where the “loop” is. Sorry.

    Reply
  11. Yannick says:
    Apr 29, 2013 at 7:38 pm

    Sry, I don´t rly get it…
    In which loop exactly do i have to paste the code?

    Maybe it´s just me being brain-afk, sry for that.

    Reply
    • Editorial Staff says:
      May 9, 2013 at 11:03 am

      In the loop where you want to display thumbnails with captions. This could be your single.php file, or any other files.

      Reply
  12. Dejan says:
    Feb 15, 2013 at 12:45 pm

    Thank you for this!!!

    Reply
  13. Jhon Edison Bueno Martinez says:
    Jul 17, 2012 at 9:16 pm

    Thanks a lot, I have been looking for this and this is the best and simple explanation of how to add the image caption for featured images.

    Thanks

    Reply
  14. Editorial Staff says:
    Mar 12, 2012 at 7:59 am

    Use this article:

    https://www.wpbeginner.com/wp-themes/how-to-display-custom-fields-outside-the-loop-in-wordpress/

    Reply
  15. tonilehtimaki87 says:
    Nov 7, 2011 at 4:26 am

    Short neat and to the point. Only critic goes for not providing example output for the short article. For other readers: Remember to read the related posts!

    Reply
  16. Gary says:
    Apr 19, 2011 at 9:51 pm

    How can I style the caption?
    It is rendering the caption line outside of the DIV class in the source code? What am I doing wrong.

    Thanks in advance,
    Gary

    Reply
    • Editorial Staff says:
      Apr 20, 2011 at 7:38 am

      You can wrap the echo content in a div of its own.

      Reply
      • t.diaz says:
        Jul 13, 2012 at 6:56 pm

        I have been banging my head against a wall for about 4 hours trying to figure out how to wrap the echo content in its own div. (PHP noob here).

        Can you give me an example of how it would look to wrap the div on that echo?

        Reply
        • Editorial Staff says:
          Jul 17, 2012 at 10:31 am

          Do it like this:

          echo ‘open div here’ . get_post(get_post_thumbnail_id())->post_excerpt . ‘close div here’;

  17. karen says:
    Mar 19, 2011 at 8:17 am

    This is great. Very helpful. Thank you so much! But it would really be helpful to show a screenshot of the result.

    Reply
  18. Bronson says:
    Mar 18, 2011 at 6:08 pm

    This little gem comes in handy when wanting to spruce up most of the free themes out there… nice, quick and easy.

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
PushEngage
PushEngage
Increase your website traffic & revenue with push notifications. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
AliDropship Coupon Code
AliDropship Coupon
Get 15% off on AliDropship WordPress and WooCommerce dropshipping plugin.
Beaver Builder Coupon Code
Beaver Builder Coupon
Get the best possible price on this easy drag-and-drop page builder plugin. From just $99 in 2020.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.