I've set up a Custom Post Type.
By default, the permalink structure is my-site.com/cpt-slug/post-title.
I would like to remove the CPT slug from the URL, so it would be just my-site.com/post-title.
How can I achieve that?
I've been playing with the Custom Rewrite Slug. It's empty by default, so I tried adding a slash /, but it broke the site. I also tried adding /%postname%/, but that wasn't successful either. Any ideas?
Thank you very much!
Meta Box does not support removing the CPT slug from the URL. You can use the code to remove post type slug from the permalink. Please follow these topics for more information
Thank you! 🙂
Just for future reference, what have worked best for me is following these steps:
Long, why doesn't metabox support removing the CPT slug from the URL? I'm rebuilding a high ranking site that was built with all pages before thus it doesn't have a "slug" before the actual page title. I'd like to refrain from creating a lot of redirects and also potentially risk losing some rankings due to url restructuring.
+1 MetaBox should support removing the CPT slug from the URL!
I can't make the code snippet work, anyone more lucky then me?
You need to add both of these PHP snippets to your site (via functions.php or using a code snippet plugin such as WPCodeBox): https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/
Then, change where it says "race" for the slug of your CPT.
After that, go to Settings > Permalinks and re-save being /%postname%/ your structure.
And it should work! 🙂 I have tested just now in a website I am working on.
Thanks Knut! I will try your solution.