注册自定义分类后在仪表板中找不到页面

时间:2016-11-14 作者:jeffimperial

出于某种原因,在为我拥有的自定义帖子类型添加自定义分类法后,我的任何页面都不会显示在仪表板中。

这只会发生在页面上。帖子,自定义帖子类型,它们都很好。

下面是我用于CPT和自定义分类法的代码。

CPT公司career

function career_post_type() {

    $labels = array(
        \'name\'                  => _x( \'Careers\', \'Post Type General Name\', \'text_domain\' ),
        \'singular_name\'         => _x( \'Career\', \'Post Type Singular Name\', \'text_domain\' ),
        \'menu_name\'             => __( \'Careers\', \'text_domain\' ),
        \'name_admin_bar\'        => __( \'Career\', \'text_domain\' ),
        \'archives\'              => __( \'Career Archives\', \'text_domain\' ),
        \'parent_item_colon\'     => __( \'Parent Career:\', \'text_domain\' ),
        \'all_items\'             => __( \'All Careers\', \'text_domain\' ),
        \'add_new_item\'          => __( \'Add New Career\', \'text_domain\' ),
        \'add_new\'               => __( \'Add New\', \'text_domain\' ),
        \'new_item\'              => __( \'New Career\', \'text_domain\' ),
        \'edit_item\'             => __( \'Edit Career\', \'text_domain\' ),
        \'update_item\'           => __( \'Update Career\', \'text_domain\' ),
        \'view_item\'             => __( \'View Career\', \'text_domain\' ),
        \'search_items\'          => __( \'Search Career\', \'text_domain\' ),
        \'not_found\'             => __( \'Not found\', \'text_domain\' ),
        \'not_found_in_trash\'    => __( \'Not found in Trash\', \'text_domain\' ),
        \'featured_image\'        => __( \'Featured Image\', \'text_domain\' ),
        \'set_featured_image\'    => __( \'Set featured image\', \'text_domain\' ),
        \'remove_featured_image\' => __( \'Remove featured image\', \'text_domain\' ),
        \'use_featured_image\'    => __( \'Use as featured image\', \'text_domain\' ),
        \'insert_into_item\'      => __( \'Insert into career\', \'text_domain\' ),
        \'uploaded_to_this_item\' => __( \'Uploaded to this career\', \'text_domain\' ),
        \'items_list\'            => __( \'Careers list\', \'text_domain\' ),
        \'items_list_navigation\' => __( \'Careers list navigation\', \'text_domain\' ),
        \'filter_items_list\'     => __( \'Filter careers list\', \'text_domain\' ),
    );
    $args = array(
        \'label\'                 => __( \'Career\', \'text_domain\' ),
        \'description\'           => __( \'Fields of career\', \'text_domain\' ),
        \'labels\'                => $labels,
        \'supports\'              => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\', \'trackbacks\', \'revisions\', ),
        \'taxonomies\'            => array( \'post_tag\' ),
        \'hierarchical\'          => false,
        \'public\'                => true,
        \'show_ui\'               => true,
        \'show_in_menu\'          => true,
        \'menu_position\'         => 5,
        \'menu_icon\'             => \'dashicons-nametag\',
        \'show_in_admin_bar\'     => true,
        \'show_in_nav_menus\'     => true,
        \'can_export\'            => true,
        \'has_archive\'           => true,
        \'exclude_from_search\'   => false,
        \'publicly_queryable\'    => true,
        \'capability_type\'       => \'post\',
    );
    register_post_type( \'career\', $args );
}
自定义分类法fields

if ( ! function_exists( \'create_fields_taxonomy\' ) ) {

    function create_fields_taxonomy() {

        $labels = array(
            \'name\'                       => _x( \'Fields\', \'Taxonomy General Name\', \'text_domain\' ),
            \'singular_name\'              => _x( \'Field\', \'Taxonomy Singular Name\', \'text_domain\' ),
            \'menu_name\'                  => __( \'Field\', \'text_domain\' ),
            \'all_items\'                  => __( \'All Items\', \'text_domain\' ),
            \'parent_item\'                => __( \'Parent Item\', \'text_domain\' ),
            \'parent_item_colon\'          => __( \'Parent Item:\', \'text_domain\' ),
            \'new_item_name\'              => __( \'New Item Name\', \'text_domain\' ),
            \'add_new_item\'               => __( \'Add New Item\', \'text_domain\' ),
            \'edit_item\'                  => __( \'Edit Item\', \'text_domain\' ),
            \'update_item\'                => __( \'Update Item\', \'text_domain\' ),
            \'view_item\'                  => __( \'View Item\', \'text_domain\' ),
            \'separate_items_with_commas\' => __( \'Separate items with commas\', \'text_domain\' ),
            \'add_or_remove_items\'        => __( \'Add or remove items\', \'text_domain\' ),
            \'choose_from_most_used\'      => __( \'Choose from the most used\', \'text_domain\' ),
            \'popular_items\'              => __( \'Popular Items\', \'text_domain\' ),
            \'search_items\'               => __( \'Search Items\', \'text_domain\' ),
            \'not_found\'                  => __( \'Not Found\', \'text_domain\' ),
            \'no_terms\'                   => __( \'No items\', \'text_domain\' ),
            \'items_list\'                 => __( \'Items list\', \'text_domain\' ),
            \'items_list_navigation\'      => __( \'Items list navigation\', \'text_domain\' ),
        );
        $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( \'fields\', array( \'career\' ), $args );

    }
    add_action( \'init\', \'create_fields_taxonomy\', 0 );

}
当我尝试删除的代码块时fields 自定义分类,页面返回并在仪表板中列出。因此,我很确定这是自定义分类法,这是这里令人不快的代码。只是我不明白为什么。

仅供参考。我已经浏览了我的插件。我甚至把它们都删除了,只是为了好玩。没有欢乐。

1 个回复
最合适的回答,由SO网友:Milo 整理而成

fields 由WordPress内部使用,不能注册为分类法或post类型slug。看看the list of Reserved Terms on the register_taxonomy Codex page 有关其他信息。

相关推荐