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

How to add author box in WordPress post

wordpress author boxBe recognized by the web is a very important element for those who want out from the crowd and it is even more for those who manage a blog or website.
Thus was born the need (if not born, born leak now) to create a sort of brand / quality indicator to associate with the result of the hard work you do to create the post. What to do? Simple, just associate the author box (including image and name-surname) of each post that has been published.
Development: 

How to monitor a mobile phone

f-secure to monitor call phone

Here, how to monitor a mobile phone:

Due to technological developments, smartphones can surf on Internet, take pictures, shoot video and keep critical data. They are key devices in our daily life and, for this reason, we very worry about losing them for stealing.

To limit the damage (and concerns)  fortunately there are solutions, such as F -Secure Mobile Security, which allow you to keep an eye on smartphones  to protect them against unauthorized use, by sending commands remotely by SMS and constantly monitoring the position geographical device by GPS.

Mobile: 

BlackBerry Messenger Voice: messaging and free calls using Wi-Fi

Research In Motion, third world power regarding the sale of smartphones, will respond to the current financial _ not bright period  with new services to which you are going to add a new operating system, BlackBerry 10, whose launch is scheduled for January 2013.
 
 
News Magazine: 

Apple News: Iphone 5s will arrive in June

news apple iphone 5sNews arrived on the iPhone 5S, smartphones that should be the successor to the iPhone 5.
 
According to what the analyst reveals Peter Misek, Apple would be convinced to launch the device in the month of June, precisely at WWDC. The production - according to Misek - will start from the month of March.
News Magazine: