使slug translatable 注册自定义帖子类型时:
register_post_type(
\'post_type_name\',
array (
\'rewrite\' => array (
\'slug\' => _x( \'post_type_name\', \'URL slug\', \'your_text_domain\' )
)
)
);
然后为要更改slug的站点创建一个小插件:
add_filter( \'gettext_with_context\', \'change_my_slug\', 10, 4 );
function change_my_slug( $translation, $text, $context, $domain )
{
if ( \'URL slug\' !== $context or \'post_type_name\' !== $text or \'your_text_domain\' !== $domain )
return $translation;
return \'changed-slug\';
}