[wp-trac] [WordPress Trac] #46265: Newly registered taxonomy adds new entries upon save

WordPress Trac noreply at wordpress.org
Sun Feb 17 15:02:19 UTC 2019


#46265: Newly registered taxonomy adds new entries upon save
---------------------------+------------------------------
 Reporter:  zethodderskov  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  assigned
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Taxonomy       |     Version:  5.0.3
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by zethodderskov):

 Bah! I can see that I messed up the function-names, trying to rename them
 to something generic. Here are the code snippet again, with correct
 function-names:


 {{{
 function foobar_init_remove_support(){
   remove_post_type_support( 'page', 'editor');
   remove_post_type_support( 'post', 'editor');
 }
 add_action('init', 'foobar_init_remove_support', 100 );


 // Register Custom Taxonomy
 function foobar_new_taxonomy() {

   $topic_labels = array(
     'name'                       => _x( 'Topics', 'Taxonomy General Name',
 'foobar_lang' ),
     'singular_name'              => _x( 'Topic', 'Taxonomy Singular Name',
 'foobar_lang' ),
     'menu_name'                  => __( 'Topics', 'foobar_lang' ),
     'all_items'                  => __( 'All topics', 'foobar_lang' ),
     'parent_item'                => __( 'Parent topic', 'foobar_lang' ),
     'parent_item_colon'          => __( 'Parent topic:', 'foobar_lang' ),
     'new_item_name'              => __( 'New topic name', 'foobar_lang' ),
     'add_new_item'               => __( 'Add new topic', 'foobar_lang' ),
     'edit_item'                  => __( 'Edit topic', 'foobar_lang' ),
     'update_item'                => __( 'Update topic', 'foobar_lang' ),
     'view_item'                  => __( 'View topic', 'foobar_lang' ),
     'separate_items_with_commas' => __( 'Separate topics with commas',
 'foobar_lang' ),
     'add_or_remove_items'        => __( 'Add or remove topics',
 'foobar_lang' ),
     'choose_from_most_used'      => __( 'Choose from the most used',
 'foobar_lang' ),
     'popular_items'              => __( 'Popular topics', 'foobar_lang' ),
     'search_items'               => __( 'Search topics', 'foobar_lang' ),
     'not_found'                  => __( 'Not found', 'foobar_lang' ),
     'no_terms'                   => __( 'No topics', 'foobar_lang' ),
     'items_list'                 => __( 'Topics list', 'foobar_lang' ),
     'items_list_navigation'      => __( 'Topics list navigation',
 'foobar_lang' ),
   );
   $topic_rewrite = array(
     'slug'                       => 'topic',
     'with_front'                 => true,
     'hierarchical'               => false,
   );
   $topic_args = array(
     'labels'                     => $topic_labels,
     'hierarchical'               => false,
     'meta_box_cb'                => 'post_categories_meta_box',
     'public'                     => true,
     'show_ui'                    => true,
     'show_admin_column'          => true,
     'show_in_nav_menus'          => true,
     'show_tagcloud'              => false,
     'rewrite'                    => $topic_rewrite,
     'show_in_rest'               => true,
   );
   register_taxonomy( 'topic', array( 'post' ), $topic_args );


 }
 add_action( 'init', 'foobar_new_taxonomy', 0 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46265#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list