Cannot get custom post type thumbnail/featured image to show in WordPress admin

220 views Asked by At

I have created three custom post types with support for thumbnails and I am trying to create a column in the admin/edit screen for the featured image/thumbnail, but I'm having no success.

The custom post types are 'publicPages', 'patreonPages', and 'exclusivePages'

This is the code I've seen people say works that I have modified for my post types:

function add_featured_image_column($defaults) {
    $defaults['featured_image'] = 'Featured Image';
    return $defaults;
}
add_filter('manage_publicPages_posts_columns', 'add_featured_image_column');
add_filter('manage_patreonPages_posts_columns', 'add_featured_image_column');
add_filter('manage_exclusivePages_posts_columns', 'add_featured_image_column');
 
function show_featured_image_column($column_name, $id) {
    if ($column_name == 'featured_image') {
        echo get_the_post_thumbnail($id, 'thumbnail'); 
    }
}
add_action('manage_publicPages_posts_custom_column', 'show_featured_image_column', 10, 2);
add_action('manage_patreonPages_posts_custom_column', 'show_featured_image_column', 10, 2);
add_action('manage_exclusivePages_posts_custom_column', 'show_featured_image_column', 10, 2);

but it hasn't worked. The rest of my CPT/child theme is working just fine - it's just this bit that I keep running into trouble with.

Happy to provide additional info as needed. Thanks in advance!

0

There are 0 answers