• Resolved madamecholet

    (@madamecholet)


    I’ve added picture captions to the featured images, but they don’t show up. Any help gratefully received

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, @madamecholet! TwentySixteen doesn’t include captions with Featured Images by default, so what you could do here is create (and activate) a Child Theme for TwentySixteen, and then add this code to the child theme’s functions.php file to override the original function from the parent theme:

    function twentysixteen_post_thumbnail() {
    	if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
    		return;
    	}
    
    	if ( is_singular() ) :
    	?>
    
    	<div class="post-thumbnail">
    		<?php the_post_thumbnail(); ?>
    		<p class="wp-caption"><?php echo get_post( get_post_thumbnail_id() )->post_excerpt; ?></p>
    	</div><!-- .post-thumbnail -->
    
    	<?php else : ?>
    
    	<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
    		<?php the_post_thumbnail( 'post-thumbnail', array( 'alt' => the_title_attribute( 'echo=0' ) ) ); ?>
    		<p class="wp-caption"><?php get_post( get_post_thumbnail_id() )->post_excerpt; ?></p>
    	</a>
    
    	<?php endif; // End is_singular()
    }
    Thread Starter madamecholet

    (@madamecholet)

    Thank you @girlieworks- that worked perfectly!

    You’re welcome, @madamecholet! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Featured picture captions in TwentySixteen’ is closed to new replies.