2012-02-10 15 views
6

Esiste un modo per creare un tipo di post personalizzato con categorie separate in wordpress?Categorie separate per i tipi di post

Esempio:

tipo Post "Notizie" dovrebbe avere le categorie "mondo" e "locale". tipo Post "Prodotti" dovrebbe avere categories: "Software" e "hardware" e io non voglio avere possibilità di impostare "Software" categoria a "Notizie" tipo posta.

C'è un modo per gestire questo?

+0

Fidati dei tuoi editor hai davvero bisogno di quel livello di granularità? – thenetimp

risposta

12

È possibile creare tipo messaggio personalizzato dal seguente esempio di codice:

function ts_post_type_test() { 
    register_post_type('Test', 
       array( 
       'label' => __('Test'), 
       'public' => true, 
       'show_ui' => true, 
       'show_in_nav_menus' => false, 
       'menu_position' => 5, 
       'capability_type' => 'post', 
       'texonomies' => array('category'), 
       'supports' => array('title','editor','thumbnail'), 
       ) 
    ); 
} 

il link del sito wordpress: http://codex.wordpress.org/Function_Reference/register_post_type

Per la categoria Crea distinta per particolare uso post seguente link:

http://codex.wordpress.org/Function_Reference/register_taxonomy

Codice di esempio:

register_taxonomy('name of taxonomy', 'post name',array("hierarchical" => true,"label" => "Label Category","singular_label" => "label of taxonomy",'update_count_callback' => '_update_post_term_count','query_var' => true,'rewrite' => array('slug' => 'slug name of new registered taxonomy', 'with_front' => false),'public' => true,'show_ui' => true,'show_tagcloud' => true,'_builtin' => false,'show_in_nav_menus' => false)); 
Problemi correlati