Hello I have a problem where i have 404 on posts after changing url with php using this function
wp_update_post( array(
'ID' => $post_id,
'post_name' => $new_slug
));
This happens in cases like the example below
if original post link abc.com/how-to-example
if I change to abc.com/how-to-example-passwd <-- redirect will still work
and I change again to a new permalink for third time redirect will work only for original link and new link and changes made between those two will return 404
Is it possible to keep all changes and make them redirect to current post using php?
I noticed wp automatically keep a custom field for the original link only