有一个全局数组$wp_post_types
. 你可以改变$wp_post_types[$post_type]->labels
在父主题设置了CPT之后。
所以…如果父主题在上注册CPT\'init\'
像这样:
add_action( \'init\', \'register_my_cpt\', 12 );
然后您需要更高的优先级:
add_action( \'init\', \'change_cpt_labels\', 13 );
…或稍后的挂钩。我会使用
wp_loaded
:
add_action( \'wp_loaded\', \'change_cpt_labels\' );
自定义帖子类型示例
place
更改为
location
add_action( \'wp_loaded\', \'wpse_19240_change_place_labels\', 20 );
function wpse_19240_change_place_labels()
{
$p_object = get_post_type_object( \'place\' );
if ( ! $p_object )
return FALSE;
// see get_post_type_labels()
$p_object->labels->name = \'Locations\';
$p_object->labels->singular_name = \'Location\';
$p_object->labels->add_new = \'Add location\';
$p_object->labels->add_new_item = \'Add new location\';
$p_object->labels->all_items = \'All locations\';
$p_object->labels->edit_item = \'Edit location\';
$p_object->labels->name_admin_bar = \'Location\';
$p_object->labels->menu_name = \'Location\';
$p_object->labels->new_item = \'New location\';
$p_object->labels->not_found = \'No locations found\';
$p_object->labels->not_found_in_trash = \'No locations found in trash\';
$p_object->labels->search_items = \'Search locations\';
$p_object->labels->view_item = \'View location\';
return TRUE;
}