This has been asked many times but each solution I’ve tried doesn’t work for me – I’m trying to remove the slug of a custom post type. I’ve tried setting
'with_front' => false,
but this also doesn’t work for me. With this suggestion, it removes the slug in the permalink within the admin area (in my case ‘locations’) but then visiting the new link I get a 404. I’ve tried flushing permalinks and this doesn’t help. However, I can still access the post by visiting /locations/post-name.
How can I solve this? Thanks in advance.
Try following code
See Reference