Generatore di Custom Post Type
register_post_type completo, senza scriverlo a memoria.
Gratuito davvero. Nessuna registrazione, nessuna email, nessun limite, nessun cookie. Non salviamo l'URL che analizzi.
Es. dashicons-book, dashicons-cart…
Codice
<?php
add_action( 'init', function () {
register_post_type( 'book', array(
'labels' => array(
'name' => 'Books',
'singular_name' => 'Book',
'add_new_item' => 'Add Book',
'edit_item' => 'Edit Book',
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-book',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'show_in_rest' => true,
'rewrite' => array( 'slug' => 'book' ),
) );
} );A cosa serve
Registrare un Custom Post Type significa ricordare a memoria decine di label e argomenti. Compili quattro campi e ottieni la funzione completa, con le label corrette e il supporto a Gutenberg già attivo.
Domande frequenti
›Perché show_in_rest è attivo?
Perché serve per usare l'editor a blocchi (Gutenberg) e le API REST con questo tipo di contenuto. Se ti serve solo l'editor classico puoi metterlo a false.