也许这并不能回答你的问题。。。但也许你可以通过改变你在$slug中的投入来适应它。
试试这个,它应该在帖子上循环并重置slug以匹配帖子名称。对于页面,添加\'post_type\' => \'page\'
到传递给get\\u posts()的数组。
$posts = get_posts(array(\'posts_per_page\' => -1));
foreach ($posts as $post) {
$slug = sanitize_title(strtolower($post->post_title));
$slug = wp_unique_post_slug($slug, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
wp_update_post(array(\'ID\' => $post->ID, \'post_name\' => $slug));
}