3

I have a post with id=1, post_title = 'Some post title' and slug(post_name)='some-post-title.

I want to update its title and slug.

$update_args = array(
    'ID' => '1',
    'post_title' => 'Test purpose',
    'post_name' => 'new-slug'
);
$result = wp_update_post($update_args);

After that post title is updated but slug stays the same(some-post-title) but not new-slug.

I cannot understand how can i update post-slug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.