Separate categories for message types

Is there a way to create a custom post type with separate categories in wordpress ?

An example :

The type of message "News" must have the categories "World" and "Local". The message type “Products” should have the categories : “Software” and “Hardware”, and I do not want to be able to set the category “Software” to the type “News”.

Is there any way to handle this?

+6
source share
1 answer

You can create your own message type by following the code example:

 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'), ) ); } 

wordpress site link: http://codex.wordpress.org/Function_Reference/register_post_type

Use the following link to create a separate category for a specific mail use:

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

Code example:

 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)); 
+12
source

Source: https://habr.com/ru/post/908147/


All Articles