以下是您的代码:
if ( isset($_GET[\'slug-update\']) ) {
$posts = get_posts();
foreach($posts as $singlepost) {
if($singlepost->post_status === \'publish\'){
$post_id = $singlepost->ID;
$current_slug = $singlepost->post_name;
$updated_slug = $current_slug . \'-word\';
}
wp_update_post( array(
\'ID\' => $post_id,
\'post_name\' => $updated_slug ) );
}
die(\'Slug Updated\');
}
将此添加到主题的功能中。php。然后使用
www.example.com/?slug-update
P、 这将只更新默认的post类型“post”(备份数据库以确保安全)
如果这有帮助,请告诉我。