How to redirect CPT permalinks from ID to default pretty permalinks?

If I understood you correctly, you will first need to redirect your user to http://domain.com/cpt1/%postname%/ and afterward, you’ll need to rewrite the URL in order to get the correct post and avoid 404 errors. So here you go: add_action( ‘template_redirect’, ‘redirect_postid_to_postname’ ); function redirect_postid_to_postname() { $uri = $_SERVER[‘REQUEST_URI’]; // Checks if the URI matches what … Read more

Page returns 404 for specific permalink

Check your database, in the postmeta table, for meta_key _wp_old_slug. When you change a slug, WP stores it and automatically redirects the old to the new, which sounds like the reason you initially couldn’t access /locations/. Once you delete the postmeta, visit Settings > Permalinks for good measure (this refreshes permalinks) and try either using … Read more