如何更改我的自定义帖子类型面板中的“所有类别”标签?

时间:2011-01-20 作者:janoChen

我刚刚创建了一个自定义帖子类型和一个自定义分类法:

// === CUSTOM TAXONOMIES === //
add_action(\'init\', \'my_custom_taxonomies\', 0);

function my_custom_taxonomies() {
    register_taxonomy(
        \'location\',     // internal name = machine-readable taxonomy name
        \'static_content\',       // object type = post, page, link, or custom post-type
        array(
            \'hierarchical\' => true,
            \'labels\' => array(
                \'name\' => __( \'Location\' ),
                \'singular_name\' => __( \'Location\' ),
                \'add_new_item\' => \'Add New Location\',
                \'edit_item\' => \'Edit Location\',
                \'new_item\' => \'New Location\',
                \'search_items\' => \'Search Location\',
                \'not_found\' => \'No Location found\',
                \'not_found_in_trash\' => \'No Location found in trash\',
            ),
            \'query_var\' => true,    // enable taxonomy-specific querying
            \'rewrite\' => array( \'slug\' => \'location\' ), // pretty permalinks for your taxonomy?
        )
    );

    wp_insert_term(\'Footer\', \'location\');
    wp_insert_term(\'Header\', \'location\');
}


// === CUSTOM POST TYPES === //
add_action( \'init\', \'create_my_post_types\' );

function create_my_post_types() {
    register_post_type( \'static_content\',
        array(
            \'labels\' => array(
                \'name\' => __( \'Static Content\' ),
                \'singular_name\' => __( \'Static Content\' ),
                \'add_new_item\' => \'Add New Static Content\',
                \'edit_item\' => \'Edit Static Content\',
                \'new_item\' => \'New Static Content\',
                \'search_items\' => \'Search Static Content\',
                \'not_found\' => \'No Static Content found\',
                \'not_found_in_trash\' => \'No Static Content found in trash\',
            ),
            \'_builtin\' => false,
            \'public\' => true,
            \'hierarchical\' => false,
            \'taxonomies\' => array( \'location\'),
            \'supports\' => array(
                \'title\',
                \'editor\',
                \'excerpt\'
            ),
            \'rewrite\' => array( \'slug\' => \'static_content\', \'with_front\' => false )
        )
    );
}
但当我进入自定义帖子类型的编辑页面时,侧栏上会显示“所有类别”它应该显示“所有位置”

如何更改标签?

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

将此添加到labels 数组:

\'all_items\' => __( \'All Locations\' ),
请参见register_taxonomy() 完整描述的文档labels 论点

结束

相关推荐