Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

Feature images not working in wordpress

Hey,

I have added support "add_theme_support( 'post_thumbnails');" for thumbnails into my functions.php file. For some reason when I want go and enter data in my custom post type, the feature image input doesn't appear.

Can someone please help. I have searched the Interwebs and can't find an answer.

7 Answers

Stanley Thijssen
Stanley Thijssen
22,831 Points

Maybe you can try this:

add_theme_support( 'post-thumbnails', array( 'your-custom-posttype-name' ) );
Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

You are a life saver! Thanks Stanley! It works. So do I do this for every custom post type I presume ?

Stanley Thijssen
Stanley Thijssen
22,831 Points

It depends.

Do you code the custom post types yourself or are u using a plugin?

But indeed you can just add the other posttypes u like to have the support

add_theme_support( 'post-thumbnails', array( 'your-custom-posttype-name', 'another', 'another2' ) );
Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

At the moment plugins (CPT UI and Advance custom fields)

Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

But thanks hey, you helped a lot!

Stanley Thijssen
Stanley Thijssen
22,831 Points

Alright,

I think if you just use add_theme_support( 'post-thumbnails' );

and you check the option 'Featured Image' at the bottom of the setting page 'Support section' of your custom post type, it should work too:)

Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

I tried it. It didn't work for some reason.

Stanley Thijssen
Stanley Thijssen
22,831 Points

make sure you change your function back to:

add_theme_support( 'post-thumbnails' );

and make sure you have selected the featured image at the support section of your custom post type settings page and it should work fine.

Jacques Esterhuizen
Jacques Esterhuizen
3,155 Points

It works now for some reason. Thanks