admin管理员组

文章数量:1025270

After updating to WP 5.1.1, my custom taxonomies do not show up under their assigned custom post types. When I comment out the custom capabilities that are attached to these custom taxonomies then they show up. I read that the Gutenberg Editor needs the Rest API Option set to true for them to show up. I have the Gutenberg Editor turned off but I tried both ways with the custom taxonomies Show in Rest API false and true. Below is the code with the custom capabilities commented out and they show up when I am logged in as admin. But when I take out the comments and have the capabilities enabled for the custom taxonomies, then they do not show up under their assigned post types in the admin.

This was all working prior to the update. When went from WP 4.9.8 to WP 5.1.1 and now they stopped showing up. We need these custom capabilities because we have a custom role for an Alert Editor they limits their use of these taxonomies.

Also, we where using the WebDev Studioes CPT UI and then a plugin made by one of the WebDev Guys called CPT UI Capabilities. Using these plugins together worked perfectly before the update. So when trying to do some debugging, I just grabbed the code and placed in my themes functions file and disabled both plugins.

After debugging, I found that the issue by just commenting out the custom capabilities for the custom taxonomies then they show up. Now I have been searching and trying everything to keep the capabilities enabled since they are requirement but cannot figure out what changed in WP core that is causing they to not be displayed now.

Any help would be greatly appreciated! Below is my code for custom taxonomies with custom capabilities commented out in order for them to show up in admin under assigned post types.

function cptui_register_my_taxes() {

    /**
     * Taxonomy: Categories.
     */

    $labels = array(
        "name" => __( "Categories", "custom-post-type-ui" ),
        "singular_name" => __( "Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        );
    register_taxonomy( "categories", array( "texrail_post" ), $args );

    /**
     * Taxonomy: Route tags.
     */

    $labels = array(
        "name" => __( "Route tags", "custom-post-type-ui" ),
        "singular_name" => __( "Route tag", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Route tags", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'route_tags', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "route_tags",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => true,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_route_tags',
        //     'edit_terms' => 'edit_route_tags',
        //     'delete_terms' => 'delete_route_tags',
        //     'assign_terms' => 'assign_route_tags',
        // )
        );
    register_taxonomy( "route_tags", array( "post", "_alerts_detours", "texrail_post" ), $args );

    /**
     * Taxonomy: GovDelivery Categories.
     */

    $labels = array(
        "name" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "singular_name" => __( "GovDelivery Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'govdelivery_categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "govdelivery_categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_govdelivery_categories',
        //     'edit_terms' => 'edit_govdelivery_categories',
        //     'delete_terms' => 'delete_govdelivery_categories',
        //     'assign_terms' => 'assign_govdelivery_categories',
        // )
        );
    register_taxonomy( "govdelivery_categories", array( "post", "page", "attachment", "portfolio-item", "wpdmpro", "_alerts_detours", "texrail_post" ), $args );

}
add_action( 'init', 'cptui_register_my_taxes' );

After updating to WP 5.1.1, my custom taxonomies do not show up under their assigned custom post types. When I comment out the custom capabilities that are attached to these custom taxonomies then they show up. I read that the Gutenberg Editor needs the Rest API Option set to true for them to show up. I have the Gutenberg Editor turned off but I tried both ways with the custom taxonomies Show in Rest API false and true. Below is the code with the custom capabilities commented out and they show up when I am logged in as admin. But when I take out the comments and have the capabilities enabled for the custom taxonomies, then they do not show up under their assigned post types in the admin.

This was all working prior to the update. When went from WP 4.9.8 to WP 5.1.1 and now they stopped showing up. We need these custom capabilities because we have a custom role for an Alert Editor they limits their use of these taxonomies.

Also, we where using the WebDev Studioes CPT UI and then a plugin made by one of the WebDev Guys called CPT UI Capabilities. Using these plugins together worked perfectly before the update. So when trying to do some debugging, I just grabbed the code and placed in my themes functions file and disabled both plugins.

After debugging, I found that the issue by just commenting out the custom capabilities for the custom taxonomies then they show up. Now I have been searching and trying everything to keep the capabilities enabled since they are requirement but cannot figure out what changed in WP core that is causing they to not be displayed now.

Any help would be greatly appreciated! Below is my code for custom taxonomies with custom capabilities commented out in order for them to show up in admin under assigned post types.

function cptui_register_my_taxes() {

    /**
     * Taxonomy: Categories.
     */

    $labels = array(
        "name" => __( "Categories", "custom-post-type-ui" ),
        "singular_name" => __( "Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        );
    register_taxonomy( "categories", array( "texrail_post" ), $args );

    /**
     * Taxonomy: Route tags.
     */

    $labels = array(
        "name" => __( "Route tags", "custom-post-type-ui" ),
        "singular_name" => __( "Route tag", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Route tags", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'route_tags', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "route_tags",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => true,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_route_tags',
        //     'edit_terms' => 'edit_route_tags',
        //     'delete_terms' => 'delete_route_tags',
        //     'assign_terms' => 'assign_route_tags',
        // )
        );
    register_taxonomy( "route_tags", array( "post", "_alerts_detours", "texrail_post" ), $args );

    /**
     * Taxonomy: GovDelivery Categories.
     */

    $labels = array(
        "name" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "singular_name" => __( "GovDelivery Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'govdelivery_categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "govdelivery_categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_govdelivery_categories',
        //     'edit_terms' => 'edit_govdelivery_categories',
        //     'delete_terms' => 'delete_govdelivery_categories',
        //     'assign_terms' => 'assign_govdelivery_categories',
        // )
        );
    register_taxonomy( "govdelivery_categories", array( "post", "page", "attachment", "portfolio-item", "wpdmpro", "_alerts_detours", "texrail_post" ), $args );

}
add_action( 'init', 'cptui_register_my_taxes' );
Share Improve this question edited Apr 5, 2019 at 15:46 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Apr 5, 2019 at 13:56 phptherightwayphptherightway 696 bronze badges 1
  • Are you sure you have these caps (e.g. manage_route_tags) assigned to your role? If I could see taxonomy only when registered without caps, I would check in the first place whether the caps are added to my role. – nmr Commented Apr 5, 2019 at 20:11
Add a comment  | 

1 Answer 1

Reset to default 0

nmr,

thanks for your suggestion. So finally had a chance to go back and do some more testing. Using your suggestion, I realized that I was missing a custom capability for my custom taxonomy. Not sure what happened to it as everything was working before my update to 5.1.1 but anyway, I found the one missing cap that would allow for my custom taxonomies to show up for the admin, added it and now it works. Problem solved!

Thanks for the suggestion.

After updating to WP 5.1.1, my custom taxonomies do not show up under their assigned custom post types. When I comment out the custom capabilities that are attached to these custom taxonomies then they show up. I read that the Gutenberg Editor needs the Rest API Option set to true for them to show up. I have the Gutenberg Editor turned off but I tried both ways with the custom taxonomies Show in Rest API false and true. Below is the code with the custom capabilities commented out and they show up when I am logged in as admin. But when I take out the comments and have the capabilities enabled for the custom taxonomies, then they do not show up under their assigned post types in the admin.

This was all working prior to the update. When went from WP 4.9.8 to WP 5.1.1 and now they stopped showing up. We need these custom capabilities because we have a custom role for an Alert Editor they limits their use of these taxonomies.

Also, we where using the WebDev Studioes CPT UI and then a plugin made by one of the WebDev Guys called CPT UI Capabilities. Using these plugins together worked perfectly before the update. So when trying to do some debugging, I just grabbed the code and placed in my themes functions file and disabled both plugins.

After debugging, I found that the issue by just commenting out the custom capabilities for the custom taxonomies then they show up. Now I have been searching and trying everything to keep the capabilities enabled since they are requirement but cannot figure out what changed in WP core that is causing they to not be displayed now.

Any help would be greatly appreciated! Below is my code for custom taxonomies with custom capabilities commented out in order for them to show up in admin under assigned post types.

function cptui_register_my_taxes() {

    /**
     * Taxonomy: Categories.
     */

    $labels = array(
        "name" => __( "Categories", "custom-post-type-ui" ),
        "singular_name" => __( "Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        );
    register_taxonomy( "categories", array( "texrail_post" ), $args );

    /**
     * Taxonomy: Route tags.
     */

    $labels = array(
        "name" => __( "Route tags", "custom-post-type-ui" ),
        "singular_name" => __( "Route tag", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Route tags", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'route_tags', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "route_tags",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => true,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_route_tags',
        //     'edit_terms' => 'edit_route_tags',
        //     'delete_terms' => 'delete_route_tags',
        //     'assign_terms' => 'assign_route_tags',
        // )
        );
    register_taxonomy( "route_tags", array( "post", "_alerts_detours", "texrail_post" ), $args );

    /**
     * Taxonomy: GovDelivery Categories.
     */

    $labels = array(
        "name" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "singular_name" => __( "GovDelivery Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'govdelivery_categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "govdelivery_categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_govdelivery_categories',
        //     'edit_terms' => 'edit_govdelivery_categories',
        //     'delete_terms' => 'delete_govdelivery_categories',
        //     'assign_terms' => 'assign_govdelivery_categories',
        // )
        );
    register_taxonomy( "govdelivery_categories", array( "post", "page", "attachment", "portfolio-item", "wpdmpro", "_alerts_detours", "texrail_post" ), $args );

}
add_action( 'init', 'cptui_register_my_taxes' );

After updating to WP 5.1.1, my custom taxonomies do not show up under their assigned custom post types. When I comment out the custom capabilities that are attached to these custom taxonomies then they show up. I read that the Gutenberg Editor needs the Rest API Option set to true for them to show up. I have the Gutenberg Editor turned off but I tried both ways with the custom taxonomies Show in Rest API false and true. Below is the code with the custom capabilities commented out and they show up when I am logged in as admin. But when I take out the comments and have the capabilities enabled for the custom taxonomies, then they do not show up under their assigned post types in the admin.

This was all working prior to the update. When went from WP 4.9.8 to WP 5.1.1 and now they stopped showing up. We need these custom capabilities because we have a custom role for an Alert Editor they limits their use of these taxonomies.

Also, we where using the WebDev Studioes CPT UI and then a plugin made by one of the WebDev Guys called CPT UI Capabilities. Using these plugins together worked perfectly before the update. So when trying to do some debugging, I just grabbed the code and placed in my themes functions file and disabled both plugins.

After debugging, I found that the issue by just commenting out the custom capabilities for the custom taxonomies then they show up. Now I have been searching and trying everything to keep the capabilities enabled since they are requirement but cannot figure out what changed in WP core that is causing they to not be displayed now.

Any help would be greatly appreciated! Below is my code for custom taxonomies with custom capabilities commented out in order for them to show up in admin under assigned post types.

function cptui_register_my_taxes() {

    /**
     * Taxonomy: Categories.
     */

    $labels = array(
        "name" => __( "Categories", "custom-post-type-ui" ),
        "singular_name" => __( "Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        );
    register_taxonomy( "categories", array( "texrail_post" ), $args );

    /**
     * Taxonomy: Route tags.
     */

    $labels = array(
        "name" => __( "Route tags", "custom-post-type-ui" ),
        "singular_name" => __( "Route tag", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "Route tags", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'route_tags', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "route_tags",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => true,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_route_tags',
        //     'edit_terms' => 'edit_route_tags',
        //     'delete_terms' => 'delete_route_tags',
        //     'assign_terms' => 'assign_route_tags',
        // )
        );
    register_taxonomy( "route_tags", array( "post", "_alerts_detours", "texrail_post" ), $args );

    /**
     * Taxonomy: GovDelivery Categories.
     */

    $labels = array(
        "name" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "singular_name" => __( "GovDelivery Category", "custom-post-type-ui" ),
    );

    $args = array(
        "label" => __( "GovDelivery Categories", "custom-post-type-ui" ),
        "labels" => $labels,
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'govdelivery_categories', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "govdelivery_categories",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => false,
        // 'capabilities' => array(
        //     'manage_terms' => 'manage_govdelivery_categories',
        //     'edit_terms' => 'edit_govdelivery_categories',
        //     'delete_terms' => 'delete_govdelivery_categories',
        //     'assign_terms' => 'assign_govdelivery_categories',
        // )
        );
    register_taxonomy( "govdelivery_categories", array( "post", "page", "attachment", "portfolio-item", "wpdmpro", "_alerts_detours", "texrail_post" ), $args );

}
add_action( 'init', 'cptui_register_my_taxes' );
Share Improve this question edited Apr 5, 2019 at 15:46 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Apr 5, 2019 at 13:56 phptherightwayphptherightway 696 bronze badges 1
  • Are you sure you have these caps (e.g. manage_route_tags) assigned to your role? If I could see taxonomy only when registered without caps, I would check in the first place whether the caps are added to my role. – nmr Commented Apr 5, 2019 at 20:11
Add a comment  | 

1 Answer 1

Reset to default 0

nmr,

thanks for your suggestion. So finally had a chance to go back and do some more testing. Using your suggestion, I realized that I was missing a custom capability for my custom taxonomy. Not sure what happened to it as everything was working before my update to 5.1.1 but anyway, I found the one missing cap that would allow for my custom taxonomies to show up for the admin, added it and now it works. Problem solved!

Thanks for the suggestion.

本文标签: custom taxonomy not showing up after adding capabilities upon updating to WP 511