把以下代码放到主题的 functions.php 文件里,然后随便访问一个网页,就对所有文章触发更新操作了。更新完记得删掉这段代码。
function update_all_posts() {
$args = array(
'post_type' => 'post',
'numberposts' => -1
);
$all_posts = get_posts($args);
foreach ($all_posts as $single_post){
$single_post->post_title = $single_post->post_title.'';
wp_update_post( $single_post );
}
}
add_action( 'wp_loaded', 'update_all_posts' );
如果你的文章数量很多的话需要改一下 PHP 的最大执行时间。