Come aggiungere il supporto delle miniature per i tipi di post personalizzati?
Il supporto delle miniature funziona per i post, ma ho un altro tipo di post chiamato product e non funziona per questo. Sto provando: add_theme_support( 'post-thumbnails', array( 'post', 'product' ) );
Sto anche utilizzando il plugin multiple post thumbnail.

Per impostazione predefinita, tutti i custom post aggiungono il supporto per Titolo e editor. Se desideri aggiungere altre funzionalità come commenti, thumbnail e revisioni, devi aggiungerle manualmente nell'argomento support.
Scopri di più su come registrare il tuo custom post type qui, puoi anche trovare la sezione relativa a support per vedere cosa puoi aggiungere.
Ecco un esempio che mostra come registrare il supporto per le thumbnail nel custom post "Libri" con il supporto per: 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'
function codex_custom_init() {
$labels = array(
'name' => _x('Libri', 'post type general name'),
'singular_name' => _x('Libro', 'post type singular name'),
'add_new' => _x('Aggiungi nuovo', 'book'),
'add_new_item' => __('Aggiungi nuovo libro'),
'edit_item' => __('Modifica libro'),
'new_item' => __('Nuovo libro'),
'all_items' => __('Tutti i libri'),
'view_item' => __('Visualizza libro'),
'search_items' => __('Cerca libri'),
'not_found' => __('Nessun libro trovato'),
'not_found_in_trash' => __('Nessun libro trovato nel cestino'),
'parent_item_colon' => '',
'menu_name' => __('Libri')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type('book',$args);
}
add_action( 'init', 'codex_custom_init' );

Stavo utilizzando post-thumbnail invece di thumbnail. Ora ha senso. post-thumbnail aggiunge la miniatura per il post ma per i custom post type serve thumbnail

Ho 'thumbnail' nel mio array 'supports' ma non riesco a salvare l'immagine in evidenza nel mio custom post.

Per i post personalizzati, prima devi abilitare il supporto per le miniature:
add_theme_support( 'post-thumbnails' );
function theme_setup() {
register_post_type( 'yourposttype', array(
...,
'supports' => array('title', ...,'thumbnail'),
));
}
add_action( 'after_setup_theme', 'theme_setup' );

Ha funzionato perfettamente per me, ma potresti spiegare perché è necessario aggiungere "add_theme_support( 'post-thumbnails' );"?
