Tagged: captions, Custom Post Type
-
AuthorPosts
-
March 13, 2017 at 2:55 pm #760034
Hi I am working (for free) on a charity web site collecting war stories. Each story is a custom post type. To add images to the story I have the following code. Unfortunately the images are not showing captions in lightbox. Do you know what php I should add to the code to get the captions to show?
$content_output .= '<div class="story-images">'; $content_output .= '<span></br><strong>Images: </br></strong></span>'; if( $images ): $content_output .= '<ul>'; foreach( $images as $image ): $content_output .= '<li>'; $content_output .= '<a class="lightbox" href="'. $image['url'].'">'; $content_output .= '<img src="'. $image['sizes']['thumbnail'].'" alt="'. $image['alt'].'" />'; $content_output .= '</a>'; $content_output .= '</li>'; endforeach; $content_output .= '</ul>'; endif; $content_output .= '</div>';If you need access login below.
Many thanks
RobMarch 15, 2017 at 8:35 am #761211Hey fanlokbun,
Thanks for providing the admin login, can you give us a link to your site?
Best regards,
NikkoMarch 15, 2017 at 11:34 am #761322Doh!
Here is a link to a custom post type (story) with 3 images:
http://shaftesbury-remembers.goldhillmuseum.org.uk/story/frederick-john-ford/
Thanks NikkoMarch 18, 2017 at 10:23 am #762855Hi,
Sorry for the late response and missing the thread. Try to add the title attribute on the img tag. Hope this helps.
Best regards,
NikkoMarch 20, 2017 at 4:30 pm #763687Nice one Nikko! Works a treat.
For anyone else I changed:
$content_output .= '<img src="'. $image['sizes']['thumbnail'].'" alt="'. $image['alt'].'" />';
to
$content_output .= '<img src="'. $image['sizes']['thumbnail'].'" alt="'. $image['alt'].'" title="'. $image['title'].'" />';
Thanks
RobMarch 21, 2017 at 6:48 am #764023Hi Rob,
Great, glad you got it working and thanks for sharing. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardMarch 21, 2017 at 11:31 am #764117Please close it
thanksMarch 22, 2017 at 12:31 am #764463Hi,
Thanks for using Enfold :)
Best regards,
Nikko -
AuthorPosts
- The topic ‘Show image captions on custom post type.’ is closed to new replies.
