Add additional text to photo caption?
-
Hi everyone,
I’m looking for a way to add additional text to the photo caption of the image.
I want to add the text ‘Image:’ to the photo caption only if the text field has been added.
I’m using this as a code: `<?php $thumb_id = get_post_thumbnail_id($post->id); $args = array( ‘post_type’ => ‘attachment’,’post_status’ => null,’post_parent’ => $post->ID,’include’ => $thumb_id);
$thumb_images = get_posts($args);
foreach ($thumb_images as $thumb_image) {
echo $thumb_image->post_excerpt;
}
?>`I tried adding
echo 'Image: ', $thumb_image->post_excerpt;
but it displays the word Image: even if it’s blank. I only want it to show up if text as been added in the caption field.Thanks,
– Gregory S.
- The topic ‘Add additional text to photo caption?’ is closed to new replies.