Winnipeg Photographer


WordPress – How to display the caption of a featured image

At the end of your functions.php template file add this code:

image

Where ever you want to display the caption of the featured image just use the function “the_post_thumbnail_caption()”. See below for an example.

image

*Please note the 3rd line should really be just a continuation of the 2nd line with a space between the “ and the height=… *


One Response

  1. Hi Jared,

    Good way of doing that. A template tag, or basically a “helper function” in the more generic terms.

    I see a lot of functions with a similar functionality adding $before and $after parameters, so that the user gets to pick what tag wraps the data.

    Thanks for sharing this on the WordPress Winnipeg LinkedIn group.

  2. Dan Bernardic on September 3rd, 2011 at 2:44 am

Leave a Reply