DEV Community

Cover image for Turning On Thumbnail Support for Custom Post Types
Simon Lee
Simon Lee

Posted on

Turning On Thumbnail Support for Custom Post Types

If you read through the functions.php file in any theme, you'll see a few lines of code that look like this:

add_theme_support('post-thumbnails');

These features are for WordPress's 2 default types: Posts and Pages. If you are working with custom post types, you'll have to add this line of code to your (for example) my-custom-post-types.php file located in your mu-plugins folder. You'll add thumbnail support inside the register_post_type() function, as shown below:

function my_custom_post_types() {
  register_post_type('event', array(
    'supports' => array('title', 'editor', 'thumbnail'),
  ));
}
Enter fullscreen mode Exit fullscreen mode

Now, when your content editors are looking at the custom post, for example, "Event", they will see the "Featured image" option in the WP Editor (lower-right hand side).

Top comments (0)