wordpress change slug programmatically
To change a WordPress post slug programmatically, you can use the wp_update_post
function. Here's an example of how to do this:
// Get the post ID
$post_id = 123;
// Get the post
$post = get_post($post_id);
// Set the new slug
$new_slug = 'new-slug';
// Update the post
wp_update_post(array(
'ID' => $post_id,
'post_name' => $new_slug,
));