How to change permalinks

Permalink settings are handled in wp-admin under Settings > Permalinks. You can select the “Post name” radio button and save the changes, and your permalinks will be updated.

If this is a live indexed site, you may want to set up redirects for search engines and visitors – that’s the only part that would require custom code.