Does anyone know how I would go about regenerating permalinks? I have a situation where I need to change titles for every post in a custom post type to a custom meta field in the post. I’ve done quite a bit of searching, but I can’t seem to find anything that does the job. All went well for the title and slug…
$new_slug = sanitize_title( get_the_title() );
$my_post = array();
$my_post['ID'] = get_the_id();
$my_post['post_title'] = esc_attr( get_post_meta( get_the_id(), 'projectSubTitle', true ) );
$my_post['post_name'] = $new_slug;
wp_update_post( $my_post );
Sorry to say, I’m not sure how permalinks are created I guess. I thought simply saving my permalink settings in wp-admin permalink settings would update my htaccess and life would be all good. Unfortunately, the old permalinks remain. I have verified that the slugs have changed in the database. Am I out of luck here…? I guess I could go into each post, remove the permalink and let wordpress generate a new one. Lot’s of posts… I’d like to avoid doing that if at all possible.
Any help or guidance is much appreciated!!