WordPress.org

Forums

[resolved] custom taxonomy tags turn into numbers (3 posts)

  1. photocurio
    Member
    Posted 8 months ago #

    I have a site with a custom post type and a custom taxonomy for that post type.

    My post type is Procedures, my taxonomy is Areas.

    My problem is that I can't select an area for a procedure—when I do, and save, I my area has changed to a new tag with a number instead of a name.

    This is the function that registers the CPT:

    add_action( 'init', 'register_cpt_procedure' );
    
    function register_cpt_procedure() {
    
        $labels = array(
            'name' => 'Procedures',
            'singular_name' => 'Procedure',
            'all_items' => 'All Procedures',
            'add_new' => 'Add New',
            'add_new_item' => 'Add New Procedure',
            'edit_item' => 'Edit Procedure',
            'new_item' => 'New Procedure',
            'view_item' => 'View Procedure',
            'search_items' => 'Search Procedure',
            'not_found' => 'No Procedure content found',
            'not_found_in_trash' => 'No Procedure content found in Trash',
            'parent_item_colon' => 'Parent Procedure item:',
            'menu_name' => 'Procedures'
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'description' => 'Procedure Custom Post Type',
            'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ),
            'taxonomies' => array('area'),
            'add_new' => 'Add New', 'procedure',
    		'add_new_item' => 'Add New Procedure',
    		'new_item' => 'New Procedure',
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 5,
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'query_var' => true,
            'can_export' => true,
            'rewrite' => true,
            'capability_type' => 'post',
            'has_archive' => true
        );
    
        register_post_type( 'procedure', $args );
    }

    And the code that registers the taxonomy:

    add_action( 'init', 'create_procedure_taxonomy', 0 );
    
    function create_procedure_taxonomy() {
    	register_taxonomy(
    		'area',
    		array(
    			'procedure'
    		),
    		array(
    			'labels' => array(
    				'name' => 'Areas',
    				'singular_name' => 'Area'
    			),
    			'rewrite' => array( 'slug' => 'area' ),
    			'hierarchical' => false,
    			'meta_box_cb' => 'post_categories_meta_box',
    			'public' => 'true'
    		)
    	);
    }
    
    register_taxonomy_for_object_type( 'area', 'procedures' );
  2. photocurio
    Member
    Posted 8 months ago #

    I have a screenshot of my admin to show what's going on.

    This is the result of my trying to select Breast as the area, and WP changing the word to a number, and unchecking Breast.

  3. photocurio
    Member
    Posted 8 months ago #

    I got this one. The solution, if anyone else has the issue, is lose this line:
    'meta_box_cb' => 'post_categories_meta_box',

Reply

You must log in to post.

About this Topic