- This topic has 17 replies, 4 voices, and was last updated 4 years, 1 month ago by Leo.
-
AuthorPosts
-
June 12, 2018 at 12:51 pm #598522Christine
Hello,
I am unable to view featured image captions. I would like to add captions to my images within posts (not to be seen on the preview menu), is there a way I can do this?
Thanks!
June 12, 2018 at 3:14 pm #598608DavidStaffCustomer SupportHi Christine,
you can add this snippet:
add_action( 'generate_before_content', 'db_featured_image_caption', 15 ); function db_featured_image_caption() { $get_description = get_post(get_post_thumbnail_id())->post_excerpt; if(!empty($get_description) && is_single() ){ echo '<span class="featured_caption">' . $get_description . '</span>'; } }
June 12, 2018 at 3:42 pm #598622ChristineHey,
I think I’m confused. I’m trying to add a visible caption underneath photos in posts, and am able to type one into the featured image photo editor (there is a box for it). Where does that caption go, if not under the photo?
I added the code you gave but nothing changed.
Thank you!
June 12, 2018 at 3:47 pm #598623ChristineOK – I see the caption if I add the image into the post… but then there are two of the same photos back to back.
June 12, 2018 at 3:53 pm #598627DavidStaffCustomer SupportHi Christine, i think i may be confused to.
So Captions are added to the Images in the Media library.
If you add a featured image to a post with a caption then the caption will be displayed below that on the post.
Is this what you needed?June 12, 2018 at 4:03 pm #598629ChristineYes, I added the caption in the Media Library. Unfortunately, I don’t think it appears when the image is used as a “Featured Image.”
June 12, 2018 at 4:09 pm #598630DavidStaffCustomer SupportDid you add the code i provided above? And if so is it sill in place?
June 12, 2018 at 4:13 pm #598631ChristineHi David,
I added it into the Simple CSS plugin and didn’t see the caption.
June 12, 2018 at 4:20 pm #598640DavidStaffCustomer SupportAah ok. the code is a PHP Snippet. The way to add the code is mentioned here:
https://docs.generatepress.com/article/adding-php/
I would advise using the Code Snippets plugin mentioned. Install plugin, paste the code into a New snippet and Save and Activate
February 17, 2020 at 2:02 pm #1168514tbgrHello.
I installed the Code Snippets plugin and entered/activated the code mentioned above:
add_action( ‘generate_before_content’, ‘db_featured_image_caption’, 15 );
function db_featured_image_caption() {
$get_description = get_post(get_post_thumbnail_id())->post_excerpt;
if(!empty($get_description) && is_single() ){
echo ‘<span class=”featured_caption”>’ . $get_description . ‘</span>’;
}
}The caption DID appear but it’s not UNDER the photo; rather it’s ABOVE the title of the blog post.
(I’m using the Marketer premium theme.)
Any suggestions? Thank you!
February 17, 2020 at 2:12 pm #1168528LeoStaffCustomer SupportAny chance you can open a new topic and link us to the page in question?
Thanks ๐
February 17, 2020 at 2:35 pm #1168542tbgrHi, Leo.
The website is under construction and isn’t live yet. Is there a way I can email you an image of the problem?
February 17, 2020 at 3:17 pm #1168561LeoStaffCustomer SupportCan you open a new topic and use this site to upload an image first?
https://postimages.org/Thanks ๐
February 17, 2020 at 3:32 pm #1168568tbgrYes. Will do in a moment.
Thank you.
February 17, 2020 at 3:37 pm #1168571tbgrJust uploaded the jpg.
Not sure if you received it.
-
AuthorPosts
- You must be logged in to reply to this topic.