Since I changed themes here I’ve been using featured images a lot more on posts. 1
There are a couple of things that bother me about WordPress featured images, the fact they do not show up in an RSS feed and that any attribution needs to go in the body of the post.
This morning I read Transforming Photo Attribution from Credit to Stories on Alan’s blog, which mentioned these problems while discussion a much more important one.
I though I’d see if it was easy enough to find a fix and headed to google.
First I found a few plugins but also some DIY advice. I decided that these looks simple enough for me.
Featured Images in RSS
All I needed to do was copy the code suggested from that site and add it to the bottom of my functions.php file which I already had in my child theme. The post shows how to edit this file via the WordPress dashboard. I do this with my ftp application.
Captions for featured images
Again there are plugins for this, but I found:
How to add caption to the featured images in WordPress which had done the trick.
This uses the built in caption from the media library. To do this I needed to copy the content-single.php file from the theme to my child themes folder. I then edited that one.
My theme’s code was slightly different to the example but it was easy enough to figure out where the code for the featured image/thumbnail was and add:
<?php if ( $caption = get_post( get_post_thumbnail_id() )->post_excerpt ) : ?> <p class="featuredcaption"><?php echo $caption; ?></p> <?php endif; ?>
After it. I also added a bit of css to the child themes styles.css file to align the text right. I’ll think about how to make that better looking….
What I particularly like is that this approach uses the built in WordPress caption for the image. When I started thinking about it I was thinking about adding a custom field and complexity. I keep finding that WordPress is already half way to do what I want, if only I knew where to look. Until I do google will keep me right.
- I choose the theme because it supports indyweb features I wanted to test. I’ve still not got my head round many of them. ↩
- This just works if you can edit your theme, so you would need a self hosted blog. I use a child theme here which should avoid changes being overwritten if the them is updated.Child Themes « WordPress Codex covers the details ↩
Also published on Medium.