Adding featured image support to your post types

Featured images are an extremely popular and handy piece of content that help make your post content stand out and shine, whether it's from you featured articles section, all the way to when shared on social media. If your theme does not already support featured images, you will need to use one of the following snippets.

Any of the following snippets you choose would need to go into your theme's functions.php

Adding support for all post types

If you want support for all post types, use the snippet below.

function my_cptui_featured_image_support() {
	add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'my_cptui_featured_image_support' );

Adding support for all Custom Post Type UI post types

If you want support for just your CPTUI post types, the snippet below can be used.

function my_cptui_featured_image_support() {
	$cptui_post_types = cptui_get_post_type_slugs();
	add_theme_support( 'post-thumbnails', $cptui_post_types );
}
add_action( 'after_setup_theme', 'my_cptui_featured_image_support' );

Adding support for specific post types

If you want support for very specific post types, this snippet will work.

function my_cptui_featured_image_support() {
	// Replace these post type slugs with the actual slugs you need support for.
	$cptui_post_types = array( 'my_post_type', 'my_other_post_type' );
	add_theme_support( 'post-thumbnails', $cptui_post_types );
}
add_action( 'after_setup_theme', 'my_cptui_featured_image_support' );