Skip to content

Working with Custom Post Types

Learn how to enable auto-generated featured images for custom post types including WooCommerce products, events, portfolios, and theme-specific post types.

Overview

WordPress Custom Post Types (CPTs) extend beyond standard posts and pages. This guide shows you how to configure Auto Featured Image to work with any custom post type.

Understanding Custom Post Types

What Are Custom Post Types?

Custom Post Types are content types beyond WordPress's default posts and pages:

Common Examples:

  • WooCommerce → Products
  • Events Calendar → Events
  • Portfolio Plugins → Portfolio Items
  • Forum Plugins → Topics, Replies
  • Custom Solutions → Any registered CPT

Enabling CPT Support

Step 1: Check Available Custom Post Types

  1. Go to Auto Featured Image > Settings > General tab
  2. Look at the Generate for post types section
  3. View all registered post types

What You'll See:

☑ Posts (post)
☐ Pages (page)
☐ Products (product) [WooCommerce]
☐ Events (tribe_events) [The Events Calendar]
☐ Portfolio (portfolio) [Theme CPT]
☐ Testimonials (testimonial) [Theme CPT]

Step 2: Enable Desired Post Types

Simply check the boxes next to the post types you want to enable:

☑ Posts
☐ Pages
☑ Products ← WooCommerce
☑ Events ← Events plugin
☑ Portfolio ← Theme feature

Click Save Settings.

WooCommerce Products Setup

Special Considerations for Products

WooCommerce products have unique characteristics:

Product Image Priority:

  1. Product gallery (first image)
  2. Product featured image (if exists)
  3. Stock image search (product name)
  4. Category default image

Troubleshooting Missing CPTs

Issue: Custom Post Type Not Showing

Possible Causes:

❌ CPT not registered with thumbnail support ❌ CPT registered after plugin loads ❌ CPT is private/not public

Solutions:

Solution 1: Add Thumbnail Support Manually

Add to theme's functions.php:

php
add_action('init', function() {
    add_post_type_support('your_cpt_name', 'thumbnail');
}, 11); // Priority 11 ensures it runs after CPT registration

Replace your_cpt_name with actual CPT slug.

Solution 2: Modify CPT Registration

If you control CPT registration:

php
register_post_type('portfolio', array(
    'supports' => array(
        'title',
        'editor',
        'thumbnail', // ← Add this
        'excerpt'
    ),
    // ... other args
));

Solution 3: Force Enable via Filter

php
add_filter('afi_enabled_post_types', function($post_types) {
    $post_types[] = 'your_cpt_slug';
    return $post_types;
});

Need Help with Your CPT?