Show description and caption of the featured image in Wordpress

featured image caption and description in wordpress
Do you want to show description of the featured image in WordPress? For example on the homepage?
 
Well, all you have to do is use this code:
----------------------------------------------------------------------
<?php
echo '<div class="re-featured-image">';
the_post_thumbnail();
echo '<div class="re-featured-image-description">' . get_post(get_post_thumbnail_id())->post_content . '</div>';
echo '</div>';
?>
---------------------------------------------------------------------

Where you must to paste this code? Depends where you want to display the image with the description. To the homepage, file is usually the index.php; for the article, the file is single.php.

Going into "technical", I use the function get_post() to retrieve information of the image (i pass the id of featured image).

The description of the image is saved as a post-content, so I'm going to read this information and show it in a div (but you might as well put it in a span) assigning the class "re-featured-image-description", so that you can configure the graphic using the style.css file.

The description is not enough for you? Here is how to show the caption of the highlights image:

------------------------------------------------------------------
<?php
echo '<div class="re-featured-image">';
the_post_thumbnail();
echo '<div class="re-featured-image-caption">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>';
echo '</div>';
?>
--------------------------------------------------------------------

Still using get_post(), I get the text in the caption, which is saved as post_excerpt.

Of course you can show both the description and the caption!

-------------------------------------------------------------------
<?php
echo '<div class="re-featured-image">';
the_post_thumbnail();
echo '<div class="re-featured-image-description">' . get_post(get_post_thumbnail_id())->post_content . '</div>';
echo '<div class="re-featured-image-caption">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>';
echo '</div>';
?>
------------------------------------------------------------------
Development: 

Similar Content

Texas Instruments fires and abandons the investment in mobile

Texas Instruments is only the latest victims of a global economic crisis and of a sector such as high-tech that would be undergoing mutations as fast as radical, to certify the state of difficulty of the group there would be a new business plan would provide numerous layoffs.
 
 
News Magazine: 

Visibility on search engines: how to defend themselves from EMD Update

emd google updateThis past September 28th Matt Cutts announced an update of the algorithms google that will make life difficult for all sites that have so far achieved visibility on search engines through the keywords included in the domain name, an update that should impact in such a way relevant to 0.6% of the queries, that has nothing to do with the Panda or Penguin, and was immediately baptized EMD Update (where EMD stands for exact-match domain).

SEO: