See: https://socal-re.com/usds-undergrad-re-program-scores-top-rank/ would like to add captions with photo credit on these images.
Thanks- Todd
See: https://socal-re.com/usds-undergrad-re-program-scores-top-rank/ would like to add captions with photo credit on these images.
Thanks- Todd
Hello @toddfmay,
Thanks for asking.
Displaying caption in featured image will require changes in theme files. Before proceeding I suggest you to setup child theme. I am sharing relevant resources that you can use to download and install child theme:
https://theme.co/apex/child-themes
After that add following code in child theme function.php file:
function x_featured_image( $cropped = '' ) {
$stack = x_get_stack();
$fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
if ( has_post_thumbnail() ) {
if ( $cropped == 'cropped' ) {
if ( $fullwidth ) {
$thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
} else {
$thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
}
} else {
if ( $fullwidth ) {
$thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
} else {
$thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
}
}
switch ( is_singular() ) {
case true:
printf( '<div class="entry-thumb">%s</div>', $thumb );
printf( '<div class="entry-caption">%s</div>', the_post_thumbnail_caption() );
break;
case false:
printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
esc_url( get_permalink() ),
esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
$thumb
);
break;
}
}
}
Please set the image caption under Media manager. https://cloudup.com/cp1vMf4wND8
Thanks.
Perfect Thanks- Todd
You’re welcome, Todd.
Sure that this code work?
I tried the code (Ethos) but I can’t see the description under the feature image…
Thank you,
Michael
Hello @mickna,
Thanks for asking.
Above code will work with Ethos stack too. However, please make sure to add the caption. https://cloudup.com/caibWM3eMVg
If you have more questions, please create a new ticket and someone from support team will definitely help you out.
Thanks.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.