Add additional text to photo caption from a custom field?
-
Hi everyone,
I’m looking for a way to add additional text using a custom field 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 $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') ); foreach ( $attachments as $attachment_id => $attachment ) { echo get_post_meta($attachment_id, 'photo_credits', true); } ?>
I tried an if statement to check the get_post_meta and it didn’t work. I only want it to show up if text as been added in the custom field called [photo_credits] field.
Thanks,
– Gregory S.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add additional text to photo caption from a custom field?’ is closed to new replies.