Nascondere il box del contenuto con Custom Post Type?

24 mag 2011, 12:11:27
Visualizzazioni: 46.1K
Voti: 25

Ho creato un custom post type e voglio nascondere l'area di testo principale (textarea) nella pagina di pubblicazione/modifica.

È possibile?

Grazie!

1
Commenti

Soluzione funzionante: https://stackoverflow.com/a/68749925/7186739

Muhammad Bilal Muhammad Bilal
12 ago 2021 02:18:13
Tutte le risposte alla domanda 5
1
47

Sì, rimuovi il supporto dell'editor dal tuo tipo di post personalizzato.

Puoi farlo in due modi.

  1. Durante la registrazione del tuo tipo di post personalizzato:

Esempio:

$args = array(
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'capability_type' => 'post',
    'has_archive' => true, 
    'supports' => array('title','author','thumbnail','excerpt','comments')
); 
register_post_type('book',$args);

2. Utilizzando remove_post_type_support se il tipo di post personalizzato non è definito dal tuo codice (cioè se un altro plugin/tema ha definito il tipo di post personalizzato).

Esempio:

add_action('init', 'my_rem_editor_from_post_type');
function my_rem_editor_from_post_type() {
    remove_post_type_support( <POST TYPE>, 'editor' );
}
24 mag 2011 12:29:48
Commenti

Puoi caricare file utilizzando il media manager, oppure creare un meta box personalizzato per gestire i caricamenti.

Hameedullah Khan Hameedullah Khan
24 mag 2011 12:52:31
0
14

Quando registri il tuo custom post type, non specificare il supporto per l'editor.

 $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,
    // nel parametro supports qui non vedi 'editor'
    'supports' => array('title','author','thumbnail','excerpt','comments') 
  ); 
  register_post_type('book',$args);

Per maggiori informazioni vedi: Riferimento Funzioni/register post type.

24 mag 2011 12:26:13
1

Puoi anche impostare

'supports' => false

per evitare il comportamento predefinito (titolo e editor).

Nota: questa opzione è valida per la versione 3.5 o superiore.

11 feb 2015 21:40:05
Commenti

Ok, come puoi generare e salvare/gestire il contenuto allora?

TomeeNS TomeeNS
26 mag 2017 19:20:25
0

Puoi rimuovere il titolo o l'editor nel modulo post dell'amministrazione

function mvandemar_remove_post_type_support() {
    remove_post_type_support( 'post', 'title' );
    remove_post_type_support( 'post', 'editor' );
}
add_action( 'init', 'mvandemar_remove_post_type_support' );
19 nov 2015 12:02:20
0

Puoi anche impostare editor a false

$supports = array(
    'title', // titolo del post
    'editor'=> false, // contenuto del post
    'author', // autore del post
    'thumbnail', // immagini in evidenza
    'excerpt', // estratto del post
    'custom-fields', // campi personalizzati
    'comments', // commenti del post
    'revisions', // revisioni del post
    'post-formats', // formati del post
);

Spero che questo ti sia utile

7 feb 2024 06:51:44