Image by anika ready to sew public domain

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

How to Show Featured Image in WordPress RSS Feed shows how to do just that. You need to edit the functions.php file in your blogs theme 2.

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.

A quick look at my feed in Forefox (Safari dos not show RSS any more 🙁 )
http://johnjohnston.info/blog/feed/ or http://feeds.feedburner.com/johnjohnston
Looks good.

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.

  1. I choose the theme because it supports indyweb features I wanted to test. I’ve still not got my head round many of them.
  2.  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.

Also on:

4 thoughts on “Tinkering with WordPress Features

  1. Thanks for figuring this out, John. I am thinking it might be easier for ordinary folks to add the code for the featured RSS via a plugin?? It’s something I find confuses people in a syndicated class, because they added their image to WordPress, but featured images exist outside of the RSS.

    If you don’t figure it out, I might 😉

    Oh never mind, it’s been done!
    https://wordpress.org/plugins/featured-image-in-rss-feed/

    It wont help my current group of students because they are in WP.com[promise]

  2. Hi Alan,

    Thanks, both things seem to have plugins that fit.
    I was confused myself by the lack of featured images in RSS.
    Certainly that would be the simplest thing for folk to do.
    It just seemed like slightly more fun and educational for me to DIY;-) Your post reminded me I had an itch to scratch.

Leave a Reply

Your email address will not be published. Required fields are marked *