Archived topic
Display Captions on Featured Images only on the post
5 replies · Started by _blank on December 31, 2020
Hi,
I used this code suggested by David in one of the questions: https://gist.github.com/diggeddy/5f7c3a4584a8beb51febc9c4f33d6c5c to add captions on the featured images, but the captions are now visible on the front page too, and they are a bit of the place on the posts.
How can i make the caption be displayed only when someone opens the post?
Hi there,
change this line:
if( $html == '' ) {
to:
if( $html == '' || !is_single() ) {
Thanks!
Could you help me getting the caption text to the left of the image, and make the links on those captions behave the same way as the rest of the links
First change your link hover CSS to this:
.entry-content a:not(.button), .featured-image .wp-caption-text a {
box-shadow: inset 0 -1px 0 currentColor;
transition: color 100ms ease-in,box-shadow .13s ease-in-out;
}
.entry-content a:not(.button):focus, .entry-content a:not(.button):hover,
.featured-image .wp-caption-text a {
box-shadow: inset 0 0 0 currentColor,0 3px 0 currentColor;
}
And then add this CSS to align the caption left and give it a little space between the image.
.featured-image .wp-caption-text {
margin-top: 10px;
text-align: left;
}
Thanks, David! You rock!
Happy New Year!
You're welcome
Happy New Year to you too!