1 Answers
To add the caption in the Feature Image, you can open the function.php file in the folder path “\wp-content\themes\dw-focus”
then add the following code:
function the_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
echo '<span class="wp_caption">'.$thumbnail_image[0]->post_excerpt.'</span>';
}
}
– Open the content-single.php file, find the line 18 then add the following code under line 18:
<?php the_post_thumbnail_caption(); ?>
Note: To style for the caption section, you can use the following code:
.single-post .entry-thumbnail .wp_caption {......}
Hope this helps !
Please login or Register to submit your answer