How to remove the slug from the permalink of a CPT
- This topic has 9 replies, 5 voices, and was last updated 2 years ago by
Val.
-
AuthorPosts
-
November 16, 2021 at 1:47 AM #31945
Knüt
ParticipantHello!
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!
November 16, 2021 at 10:52 AM #31956Long Nguyen
ModeratorHi,
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
https://wordpress.org/support/topic/removing-slug-in-url-from-custom-post-type/
https://stackoverflow.com/questions/41230665/how-to-remove-taxonomy-slug-from-custom-post-type-urlNovember 16, 2021 at 3:19 PM #31979Knüt
ParticipantThank you! 🙂
March 24, 2023 at 2:53 PM #41197Knüt
ParticipantJust for future reference, what have worked best for me is following these steps:
https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/May 18, 2023 at 6:39 AM #41841Josh
ParticipantLong, 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.
June 2, 2023 at 9:01 PM #42025Francesco
Participant+1 MetaBox should support removing the CPT slug from the URL!
June 2, 2023 at 9:18 PM #42026Francesco
ParticipantI can't make the code snippet work, anyone more lucky then me?
June 14, 2023 at 12:44 AM #42188Knüt
ParticipantHello Francesco!
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.
June 19, 2023 at 4:17 PM #42271Francesco
ParticipantThanks Knut! I will try your solution.
January 31, 2024 at 2:41 PM #44438Val
ParticipantThis plugin did the trick for me - https://wordpress.org/plugins/permalink-manager/
But I'm as well thinking Meta Box should have this feature built in.
-
AuthorPosts
- You must be logged in to reply to this topic.