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

Tutorial Drupal Views: How to create a view

ui drupal views

Drupal Views: guide and notes
The Views module allows webmasters to drupal to create, manage and display lists of content and therefore a way of presenting the contents and tables. Essentially it is a query builder that, given some information, it can create queries, execute and lead to visual data in pages, blocks or other formats. Every single view can also have multiple views.
Development: 

Winning scheme by Bob Stone: formula in 7 steps

bob stone and direct marketingThe sales letter is one of the final and decisive steps of a good marketing campaign, you may have done a great job previous to carry you until the decisive moment, the purchase, but if you're wrong on this step then all the work will be in vain.

The sales letter is the key factor when it represents the instrument in the hands of marketers to convince the user to take the final step, the purchase. In this regard, it seems appropriate to remember the one who can be considered logically the father of Direct Marketing, which Bob Stone.

Web Marketing: 

Megaupload 2.0 will be called Mega and will be unassailable

megaupload 2.0Megaupload will return with the simple name of "Mega", and it seems that this time Kim Dotcom has definitely put protected from possible complaints and raid at home. The new service provides fact that files uploaded by users to be protected by encryption, and the keys are not in possession of directors.
Money Making Systems: 

Here are four goals that every company should measure on social media

social media globeYour social media activity is improvised? You do not know what to take?

The term "Social Media ROI" is often used at random, but in fact it is known that it is very important to our business!
 
But where to start and how right place himself in the online measurement of our overall business objectives?
Web Marketing: 

LG Nexus 4: The first official pictures

Come back from evleaks new images on the Nexus 4 of LG which will be presented on 29 October by Google.

This time, as you can see, the back is completely missing the logo "with Google" that had doubt many users and has made ​​his first appearance the logo "Nexus" as some had originally said.

News Magazine: