• Resolved yeru

    (@yeru)


    There are many nice images to be used as featured images/thumbnails, which are licenced under Creative Commons (CC). In order to properly and legally safely use them, the licence must be named and linked in the caption.

    The Stockholm theme originally does not feature captions for featured images.
    Another theme I know well (Urwahl 3000) uses this code in the content-single.php file to display the caption:

    <?php if ( has_post_thumbnail() ): ?>
    	[...]
    	<?php $imgexc = get_post(get_post_thumbnail_id())->post_excerpt;
    		if ($imgexc != "") {
    			?><p class="caption"><span>[...] <?php echo $imgexc;?></span></p><?php 
    		} ?>
    <?php endif; ?>

    I checked all files of the Stockholm theme for any thumbnail-reference. Only functions.php defines thumbnail support.
    My question is simply: In which file can I inject the code in order to display featured image captions?

Viewing 1 replies (of 1 total)
  • Thread Starter yeru

    (@yeru)

    Got it myself: you have to change the blog_single-loop.php file, which is located at .../themes/stockholm/templates/blog

    In the .php file, you’ll find the lines

    if ( has_post_thumbnail() ) { ?>
       <div class="post_image">
       <?php the_post_thumbnail('blog_image_in_grid'); ?>
       </div>

    Add the following under this:

    <p align="right" class="caption" style="font-size:small"><i class="fa fa-picture-o"></i>
     <?php
     echo get_post(get_post_thumbnail_id())->post_excerpt;
     ?>
     </p>
    

    The essential part is the <php> code. The rest changes the font, the alignment and inserts a nice font-awesome-icon.

Viewing 1 replies (of 1 total)
  • The topic ‘[Stockholm] Add caption to featured image/thumbnail’ is closed to new replies.