I want to show the caption of the post thumbnail, there's a couple of methods out there, but none of them displays the caption properly, the caption just float and not displayed under the image! I want to wrap the image in wp-caption div, like any other images with caption.
Here is the function I've tried
function monahans_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) { $attachment =& get_post($post_thumbnail_id); // post_title => image title // post_excerpt => image caption // post_content => image description if ($attachment->post_excerpt || $attachment->post_content) { $html .= ''; if ($attachment->post_excerpt) { $html .= ''.$attachment->post_excerpt.' '; } $html .= $attachment->post_content.''; } return $html; } add_action('post_thumbnail_html', 'monahans_thumbnail_caption', null, 5);
As I said, the caption doesn't show properly at all:
I want a function to wrap the image inside wp-caption
div, and wrap the caption text inside wp-caption-text
wp-caption
. I know I can do this by JS and CSS, but I just want a php function to do that.