Title: Add caption functionality to custom wordpress theme
Last modified: August 30, 2016

---

# Add caption functionality to custom wordpress theme

 *  Resolved [Sai29180](https://wordpress.org/support/users/sai29180/)
 * (@sai29180)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/add-caption-functionality-to-custom-wordpress-theme/)
 * Hi I am working from a custom theme created by my predecessor and I am trying
   to add caption functionality to the theme but I am have some trouble with it.
   
   Presently if I insert a image into a [post](http://www.hurford-salvi-carr.co.uk/blog/city-road-update-ec1?preview=true&preview_id=21048&preview_nonce=5cf55afefd)
   and wish to add a caption, the caption would just appear next to the picture 
   without any tags or classes containing it, here is a [pic](http://imgur.com/yIPPKwl).
   I tried following another [post](http://stackoverflow.com/questions/13850313/how-to-add-a-featured-image-caption-in-wordpress)
   and adding this piece of code to the function.php and to my single.php but nothing
   changed.
 *     ```
       function the_post_thumbnail_caption() {
         global $post;
   
         $thumbnail_id    = get_post_thumbnail_id($post->ID);
         $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
   
         if ($thumbnail_image && isset($thumbnail_image[0])) {
           echo '<span>'.$thumbnail_image[0]->post_excerpt.'</span>';
         }
       }
       ```
   
 * `<?php the_post_thumbnail(); ?>`
 * What do I have to include to implement captions properly under my images?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Sai29180](https://wordpress.org/support/users/sai29180/)
 * (@sai29180)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/add-caption-functionality-to-custom-wordpress-theme/#post-6690232)
 * I found the issue to be a plugin, and added wp-caption css to my styles found
   
   here [https://codex.wordpress.org/CSS](https://codex.wordpress.org/CSS)

Viewing 1 replies (of 1 total)

The topic ‘Add caption functionality to custom wordpress theme’ is closed to new
replies.

## Tags

 * [captions](https://wordpress.org/support/topic-tag/captions/)
 * [custom theme](https://wordpress.org/support/topic-tag/custom-theme/)

 * 1 reply
 * 1 participant
 * Last reply from: [Sai29180](https://wordpress.org/support/users/sai29180/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/add-caption-functionality-to-custom-wordpress-theme/#post-6690232)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
