对于任何有相同问题的人,我现在使用的是以下问题的公认答案中的解决方法:https://wordpress.stackexchange.com/a/30723/181214
我使用的解决方案超出了;编辑:另一个选项;这对鼻涕虫、名字、单数名字等都适用。
function get_labels() {
// return a default slug
if(!defined(\'WPLANG\') || !WPLANG || \'de_DE\' == WPLANG) return array(\'slug\' => \'produkt\', \'name\' => \'Produkte\', \'singular_name\' => \'Produkt\');
$slugs = array(
\'en_US\' => array(\'slug\' => \'product\', \'name\' => \'Products\', \'singular_name\' => \'Product\'),
\'en_UK\' => array(\'slug\' => \'product\', \'name\' => \'Products\', \'singular_name\' => \'Product\'),
\'de_DE\' => array(\'slug\' => \'produkt\', \'name\' => \'Produkte\', \'singular_name\' => \'Produkt\'),
\'de_CH\' => array(\'slug\' => \'produkt\', \'name\' => \'Produkte\', \'singular_name\' => \'Produkt\'),
\'fr_FR\' => array(\'slug\' => \'produit\', \'name\' => \'Produits\', \'singular_name\' => \'Produit\'),
\'es_ES\' => array(\'slug\' => \'producto\', \'name\' => \'Productos\', \'singular_name\' => \'Producto\')
);
return $slugs[WPLANG];
}
function product() {
$labels = get_labels();
register_post_type(\'product\',
array(
\'labels\' => array(
\'name\' => $labels[\'name\'],
\'singular_name\' => $labels[\'singular_name\'],
),
\'public\' => true,
\'has_archive\' => true,
\'show_ui\' => true,
\'rewrite\' => array(
\'slug\' => $labels[\'slug\']
),
\'show_in_menu\' => true,
\'supports\' => array(
\'title\',
\'post-thumbnail\',
)
)
);
}
add_action(\'init\', \'product\');