How to remove the slug from the permalink of a CPT

Support General How to remove the slug from the permalink of a CPTResolved

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #31945
    KnütKnüt
    Participant

    Hello!

    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!

    #31956
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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-url

    #31979
    KnütKnüt
    Participant

    Thank you! 🙂

    #41197
    KnütKnüt
    Participant

    Just for future reference, what have worked best for me is following these steps:
    https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/

    #41841
    JoshJosh
    Participant

    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.

    #42025
    FrancescoFrancesco
    Participant

    +1 MetaBox should support removing the CPT slug from the URL!

    #42026
    FrancescoFrancesco
    Participant

    I can't make the code snippet work, anyone more lucky then me?

    #42188
    KnütKnüt
    Participant

    Hello 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.

    #42271
    FrancescoFrancesco
    Participant

    Thanks Knut! I will try your solution.

    #44438
    ValVal
    Participant

    This 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.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.