自定义分类不在POST区域中显示术语

时间:2014-10-29 作者:Kareem

我创建了一个名为Country 收集帖子(即使来自不同类别)country 条款。我使用了以下代码,创建了术语,没有问题:

function country_init() {
    register_taxonomy(
        \'country\',
        \'post\',
        array(
            \'label\' => __( \'Country\' ),
            \'show_ui\' => true,
            \'update_count_callback\' => \'_update_post_term_count\',
            \'show_admin_column\' => true,
            \'show_in_nav_menus\' => true,
            \'rewrite\' => array( \'slug\' => \'country\' ),
            \'capabilities\' => array(
                \'manage_terms\' => \'manage_options\',
                \'edit_terms\'   => \'manage_options\',             
                \'assign_terms\' => \'edit_guides\',
            )
        )
    );
}
add_action( \'init\', \'country_init\' );
在创建新的时,我无法选择这些术语post. 窗口小部件区域显示名为country, 但不切换任何内容,如下图所示。而且没有country 创建菜单或小部件时的框。

empty widget

代码有问题吗?

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

似乎是在制造一些冲突。你能试试这个代码吗?

add_action( \'init\', \'country_init\' );

function country_init() {

    $labels = array( 
        \'name\' => _x( \'Countries\', \'countries\' ),
        \'singular_name\' => _x( \'Country\', \'countries\' ),
        \'search_items\' => _x( \'Search Countries\', \'countries\' ),
        \'popular_items\' => _x( \'Popular Countries\', \'countries\' ),
        \'all_items\' => _x( \'All Countries\', \'countries\' ),
        \'parent_item\' => _x( \'Parent Country\', \'countries\' ),
        \'parent_item_colon\' => _x( \'Parent Country:\', \'countries\' ),
        \'edit_item\' => _x( \'Edit Country\', \'countries\' ),
        \'update_item\' => _x( \'Update Country\', \'countries\' ),
        \'add_new_item\' => _x( \'Add New Country\', \'countries\' ),
        \'new_item_name\' => _x( \'New Country\', \'countries\' ),
        \'separate_items_with_commas\' => _x( \'Separate countries with commas\', \'countries\' ),
        \'add_or_remove_items\' => _x( \'Add or remove countries\', \'countries\' ),
        \'choose_from_most_used\' => _x( \'Choose from the most used countries\', \'countries\' ),
        \'menu_name\' => _x( \'Countries\', \'countries\' ),
    );

    $args = array( 
        \'labels\' => $labels,
        \'public\' => true,
        \'show_in_nav_menus\' => true,
        \'show_ui\' => true,
        \'show_tagcloud\' => true,
        \'show_admin_column\' => false,
        \'hierarchical\' => true,

        \'rewrite\' => true,
        \'query_var\' => true
    );

    register_taxonomy( \'countries\', array(\'post\'), $args );
}

结束

相关推荐