这应该是诀窍。
function acervo_permalink($permalink, $post_id, $leavename){
if (get_option('permalink_structure') != ''){
$post = get_post($post_id);
$rewritecode = array(
'%acervo%'
);
if (strpos($permalink, '%acervo%') !== FALSE){
$terms = wp_get_object_terms($post->ID, 'acervo');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $acervo = $terms[0]->slug;
else $acervo = '';
}
$rewritereplace = array(
$acervo
);
$permalink = str_replace($rewritecode, $rewritereplace, $permalink);
}
return $permalink;
}