My custom post type not show category

i have a problem, my ctp work, but when add new project, on the menu of right not show category

this is my code:

//
//***********************************************************//
//****************portfolio progetti   **********************//
//***********************************************************//
//***********************************************************//

function custom_post_type_prog() {
 
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Progetti di Area', 'Post Type General Name', 'generatepress' ),
        'singular_name'       => _x( 'Progetto', 'Post Type Singular Name', 'generatepress' ),
        'menu_name'           => __( 'Progetti', 'generatepress' ),
        'parent_item_colon'   => __( 'Parent Progetto', 'generatepress' ),
        'all_items'           => __( 'Tutti i progetti', 'generatepress' ),
        'view_item'           => __( 'Vedi Progetto', 'generatepress' ),
        'add_new_item'        => __( 'Aggiungi nuovo progetto', 'generatepress' ),
        'add_new'             => __( 'Aggiungi progetto', 'generatepress' ),
        'edit_item'           => __( 'Edit Progetto', 'generatepress' ),
        'update_item'         => __( 'Update Progetto', 'generatepress' ),
        'search_items'        => __( 'Search Progetto', 'generatepress' ),
        
        'not_found'           => __( 'Not Found', 'generatepress' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'generatepress' ),
    );
     
// Set other options for Custom Post Type
     
    $args = array(
        'label'               => __( 'Progetti', 'generatepress' ),
        'description'         => __( 'Progetti di area-55', 'generatepress' ),
        'labels'              => $labels,
        'supports'            => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky'),
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'menu_icon'           => 'dashicons-hammer',
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
        'show_in_rest'        => true,
        // This is where we add taxonomies to our CPT
        'taxonomies'          => array( 'progetti_cat','post_tag' ),
    );
     
    // Registering your Custom Post Type
    register_post_type( 'progetti', $args );
 
}

 add_action( 'init', 'custom_post_type_prog', 0 );


add_action( 'init', 'custom_taxonomy' );

// Register Custom Taxonomy
function custom_taxonomy() {

    $labels = array(
        'name'                       => _x( 'Categorie progetti', 'Taxonomy General Name', 'generatepress' ),
        'singular_name'              => _x( 'Categoria Progetto', 'Taxonomy Singular Name', 'generatepress' ),
        'menu_name'                  => __( 'Categoria Progetti', 'generatepress' ),
        'all_items'                  => __( 'All Items', 'generatepress' ),
        'parent_item'                => __( 'Parent Item', 'generatepress' ),
        'parent_item_colon'          => __( 'Parent Item:', 'generatepress' ),
        'new_item_name'              => __( 'New Item Name', 'generatepress' ),
        'add_new_item'               => __( 'Add New Item', 'generatepress' ),
        'edit_item'                  => __( 'Edit Item', 'generatepress' ),
        'update_item'                => __( 'Update Item', 'generatepress' ),
        'view_item'                  => __( 'View Item', 'generatepress' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'generatepress' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'generatepress' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'generatepress' ),
        'popular_items'              => __( 'Popular Items', 'generatepress' ),
        'search_items'               => __( 'Search Items', 'generatepress' ),
        'not_found'                  => __( 'Not Found', 'generatepress' ),
        'no_terms'                   => __( 'No items', 'generatepress' ),
        'items_list'                 => __( 'Items list', 'generatepress' ),
        'items_list_navigation'      => __( 'Items list navigation', 'generatepress' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'progetti_cat', array( 'progetti' ), $args );

}

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

the $args need to onclude 'show_in_rest' => true

from https://developer.wordpress.org/reference/functions/register_taxonomy/

‘show_in_rest’
(bool) Whether to include the taxonomy in the REST API. Set this to true for the taxonomy to be available in the block editor.
Blockquote


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x