- This topic has 11 replies, 4 voices, and was last updated 2 years, 1 month ago by Ying.
-
AuthorPosts
-
August 5, 2022 at 2:05 pm #2304701auerbach
In Pathogenews.com, I recently revised the Home page to add a thumbnail of each post’s Featured Image to the Excerpts that appears on Home. This works fine.
However, the captions on images (which have these) do not appear in the posts or excerpts.
I just added this CSS in an attempt to right-align the captions:
p.wp-caption-text.thumb-caption-text {
text-align: right;
line-height: 22.5px;
margin-top: 0.5em;
}That seems to have corrected a previous problem (the featured images showed up in a “squashed” format in some excerpts), but as previously, the captions still do not display.
I’d welcome any suggestions.
Alex
August 5, 2022 at 3:59 pm #2304744YingStaffCustomer SupportHi there,
I’m not sure I fully understand your question, captions won’t show up for featured images by default.
Do you want the featured image to show its caption on the homepage?
August 5, 2022 at 4:54 pm #2304766auerbachHi Ying. Thanks for the quick response. Yes, I would like the caption to show up BOTH in the post itself AND in the excerpt on the Home page.
I did not understand that captions don’t show up by default; the Featured Image entry area does have a place to enter a caption, which I think to most users would suggest that the caption displays on the page.
Please let me know how to override this default and have the caption display in the post and in the excerpt.
If it is not possible for both the post and excerpt to display the caption, can I place a standard image in the text of the post, using “Insert Media,” and also have that image also display in the excerpt on the Home page?
Alex
August 6, 2022 at 3:04 am #2304965DavidStaffCustomer SupportHi there,
try adding this PHP Snippet to your site:
add_action( 'post_thumbnail_html', 'db_auto_single_featured_caption', 10 ); function db_auto_single_featured_caption( $html ) { $caption = get_the_post_thumbnail_caption(); if ( !empty($caption) ){ $html .= '<div class="wp-caption">'. $caption . '</div>'; } return $html; }
August 6, 2022 at 10:12 pm #2305497auerbachThanks, David. That did it!
August 7, 2022 at 5:37 am #2305691DavidStaffCustomer SupportGlad to hear that!
August 16, 2022 at 12:51 pm #2314962auerbachHi Again.
The solution above added the featured image to excerpts and posts. Thank you for that.
However, the handling of captions (which I use on only some featured images) is a problem.
The captions display correctly on the Home page. But in full-page posts, the captions overlay the photos. For example, see https://pathogenews.com/treatment-for-tinnitus/, https://pathogenews.com/long-acting-injectable-drug-for-tuberculosis/, https://pathogenews.com/potential-long-term-treatment-for-asthma/, etc.
Please tell me how to move the captions down slightly on the full pages, while leaving them as is when viewed in the excerpts on the Home page.
Also, I’d like the captions to center under the images, rather than aligning to the right. (I’ve tried changing the CSS (of which my knowledge is quite limited), but without success.
See the private information below.
Thanks,
Alex
August 16, 2022 at 5:52 pm #2315090Fernando Customer SupportHi Alex,
You can try adding this CSS in Appearance > Customize > Additional CSS:
.single .featured-image .wp-caption { line-height: 1.5; text-align:center; }
August 17, 2022 at 1:43 pm #2315963auerbachHi Fernando,
Thanks so much for the quick response. It worked, moving the caption lower and centering it in the full-page posts!
However, in the excerpts on the Home page, the captions are not centered. Can I impose on you for advice on how to center these as well?
I appreciate your help!
August 17, 2022 at 3:02 pm #2315998YingStaffCustomer SupportHi there,
You can change Fernando’s CSS to this:
.wp-caption { line-height: 1.5; text-align:center; }
August 17, 2022 at 4:05 pm #2316021auerbachThanks, Ying. That did it!
August 18, 2022 at 9:42 am #2316846YingStaffCustomer SupportYou are welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.