A few days ago a client asked me to look at their WordPress powered website. Self-hosted not wordpress.com as you probably already assumed. They said they could not find where to designate a featured image for their posts. They had installed a plugin, a recent posts slider actually, that needed the featured image. Even before digging in the admin dashboard I already had a hunch. I asked, “Are you sold on the theme you’re using? I mean are you happy with the layout and performance?” When they indicated they did not want to change themes I was pretty sure what I needed to do.
Themes control the User Experience (UX) in WordPress. If you take away the theme there’s nothing. If you create a simple theme with no Cascading Style Sheet (CSS), it’s just raw text and uncontrolled images. When theme developers work with theme designers, they make the choice about how they want the theme to appear to the screen on both big screens and small screens.
For this particular theme, the decision was evidently made to leave off a simple line of code that adds functionality for featuring images in posts, pages, or both. These featured images can later be “hooked” to be used in the theme, widgets, or plugins.
Heads up! What you are about to do isn’t difficult unless you do it wrong. So follow these steps (if you have not already done so) before you start:
- Create at least a basic child theme with a functions.php file
- Switch to the child theme in Appearance > Themes
- Back-up your content and database
- Recheck that you did both of the above
Now you’re ready to begin. You’re going to be able to do this all through the admin dashboard provided you did step 1 properly. The reason you want a child theme is so that your work isn’t overwritten when you update your theme. First though, you need to decide if you want your new function, featured images, to be active in only posts, only pages, or both posts and pages. THEN you’re ready to begin.
- Go to Appearance > Editor
- Click on functions.php in the right sidebar
- Somewhere after <?php and before the end of the file type
The above adds support to both posts and pages. If you only want to add support to posts use
and if you only want to add support to pages use
4. Click “Update File”
There are also other attributes but most of them are unnecessary for basic inclusion. You can read about them at https://codex.wordpress.org/Theme_Development.