0

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 );

}
2

1 Answer 1

0

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

3
  • yes it is already on true
    – Exolon
    Commented Feb 15, 2021 at 23:31
  • I was referring to the // Register Custom Taxonomy function custom_taxonomy() near the end of your code.
    – Michael
    Commented Feb 15, 2021 at 23:52
  • ok solved thanks
    – Exolon
    Commented Feb 16, 2021 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.