Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
Created October 12, 2015 16:40
Show Gist options
  • Select an option

  • Save SiGaCode/9e5016006220194ea628 to your computer and use it in GitHub Desktop.

Select an option

Save SiGaCode/9e5016006220194ea628 to your computer and use it in GitHub Desktop.
Show both caption AND description of a picture on pages/posts. http://wordpress.stackexchange.com/questions/48117/how-to-show-description-under-an-inserted-image (Third suggestion from Kovah)
add_shortcode('wp_caption', 'img_caption_add_description');
add_shortcode('caption', 'img_caption_add_description');
function img_caption_add_description($attr, $content = null)
{
$post_id = str_replace('attachment_', '', $attr['id']);
$img = get_post((int)$post_id);
if (is_a($img, 'WP_Post')) {
$attr['caption'] = $img->post_content;
}
return img_caption_shortcode($attr, $content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment