Created
October 12, 2015 16:40
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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