Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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
    Rob

    #761211

    Hey fanlokbun,

    Thanks for providing the admin login, can you give us a link to your site?

    Best regards,
    Nikko

    #761322

    Doh!
    Here is a link to a custom post type (story) with 3 images:
    http://shaftesbury-remembers.goldhillmuseum.org.uk/story/frederick-john-ford/
    Thanks Nikko

    #762855

    Hi,

    Sorry for the late response and missing the thread. Try to add the title attribute on the img tag. Hope this helps.

    Best regards,
    Nikko

    #763687

    Nice 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
    Rob

    #764023

    Hi 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,
    Rikard

    #764117

    Please close it
    thanks

    #764463

    Hi,

    Thanks for using Enfold :)

    Best regards,
    Nikko

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Show image captions on custom post type.’ is closed to new replies.