Connect with us

DOWNLOAD APK/APP

How to

How to Display The WordPress Featured Image Caption Without a Plugin

Published

on

5
(1)

How To Display The WordPress Featured Image Caption Without A Plugin

This WordPress code will allow you to display the image caption for the featured image in your WordPress posts without using a plugin.

Instructions
Add this code to your theme template (eg. single.php) where you are displaying the image.<?php if (get_post( get_post_thumbnail_id())->post_content); // check if image has caption added ?> <div class="featured_image_caption"> <?php echo wp_kses_post(get_post( get_post_thumbnail_id() )->post_content ); // outputs image caption ?> </div><?php endif; ?>

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

READ  How to Display the Current Time in WordPress Local Language

Shedrach uzogazie Techfarns co-founder and an aspiring entrepreneur who keeps a close eye on open source, tech giants, and security. Get in touch with him by sending an email — techfarns@gmail.com

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: