Hi @soylm,
To get the result as you desired, you must activate the child theme. You can get knowledge about the child theme and download the ColorMag child theme from the link below.
https://themegrill.com/blog/tutorial-creating-wordpress-child-theme/
Now that if you’ve downloaded and activated the child theme, then add the below code in a file name functions.php.
add_filter( 'post_thumbnail_html', 'custom_add_post_thumbnail_caption',10,5 );
function custom_add_post_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) {
if( $html == '' ) {
return $html;
} else {
$out = '';
$thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
$image = wp_get_attachment_image_src($post_thumbnail_id, $size);
if($thumbnail_image[0]->post_excerpt)
$out .= '<div class="wp-caption thumb-caption">';
$out .= $html;
if($thumbnail_image[0]->post_excerpt)
$out .= '<p class="wp-caption-text thumb-caption-text">'.$thumbnail_image[0]->post_excerpt.'</p></div>';
}
return $out;
}
}
Thanks and Regards,
Ankit
Thread Starter
soylm
(@soylm)
@tgboy it worked! Thank you!
but I have a problem, at the beginning of the page, the legend of the featured image is seen behind the title of the post, and it looks bad, can’t it be fixed?
capture of the problem: https://i.imgur.com/ghqLCRv.png
Hi there,
Can you provide us the URL of your website so that we can inspect it and give you a better solution?
Thanks.