我试图改变演员的角色基础,但当刷新永久链接时,一切都保持不变。我正在使用我发现的以下代码来实现它:
function space_change_custom_taxonomy_slug_args( $taxonomy, $object_type, $args ){
if( \'actor\' == $taxonomy ){ // Instead of the "old-slug", add current slug, which you want to change.
remove_action( current_action(), __FUNCTION__ );
$args[\'rewrite\'] = array( \'slug\' => \'star\' ); // Instead of the "new-slug", add a new slug name.
register_taxonomy( $taxonomy, $object_type, $args );
}
}
add_action( \'registered_taxonomy\', \'space_change_custom_taxonomy_slug_args\', 10, 3 );
该主题具有以下寄存器分类:
// Now register the non-hierarchical taxonomy like tag
register_taxonomy(\'actors\',\'post\', array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'show_in_rest\' => true,
\'rewrite\' => array( \'slug\' => \'actor\' )
));
我不知道我做错了什么。我有一个疑问。最好在函数中使用此代码,或在中使用url重写规则。htaccess?