Jump to content

Need help getting the featured image caption to display in Divi theme


simcoweb

Recommended Posts

Greetings. I'm using the Divi theme from Elegant Themes for a new magazine style project. The theme does not display the caption for any of its image related modules and the featured image that displays in the posts as the thumbnail does not.

We need the caption to display for legal reasons since it will attribute the source of the image. Here's the code they use for their theme display in the single.php file:

} else if ( ! in_array( $post_format, array( 'gallery', 'link', 'quote' ) ) && 'on' === et_get_option( 'divi_thumbnails', 'on' ) && '' !== $thumb ) {
									print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
									echo wp_kses_post(get_post(get_post_thumbnail_id())->post_excerpt);
									} else if ( 'gallery' === $post_format ) {
									et_pb_gallery_images();
								}

Basically this is a custom function instead of using the standard Wordpress function. I searched around the Wordpress plugin repository and found someone who posted this code as a possible fix:

<div class="et_post_meta_wrapper">
...
<?php if (get_post(get_post_thumbnail_id())->post_excerpt) { // search for if the image has caption added on it ?>
	<div class="featured-image-caption">
		<?php echo wp_kses_post(get_post(get_post_thumbnail_id())->post_excerpt); // displays the image caption ?>
	</div>
<?php } ?>

</div> <!-- .et_post_meta_wrapper -->

The problem is, where he says to insert this (just before the closing </div> tag for the wrapper, ) the caption displays at the bottom of the page, not underneath the featured image. I'm thinking that this code can be adapted to the same section of the code I posted above so that it all works as one unit in summoning the thumbnail and the caption.

However, my PHP skills are not up to speed in order to conjure up the correct syntax for merging these two. Any help would be greatly appreciated. Thanking everyone in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.