• Resolved Chris

    (@osiak)


    Hello,
    is it possible to add a custom prefix to the CPT permalink structure?
    My CPT name is eg. books so my default permalink for posts would be mysite.com/books/post-name. However my CPT in terms of the page navigation is under a higher/parent menu, eg. Products. So I’d like to have a permalink for each of my books post as mysite.com/products/books/post-name. I tried adding /products/ in the Custom Rewrite Slug setting which makes the post permalink as I want, but when opening the post the page returns a 404 page. Tried flushing permalink structure, but didn’t help.
    Any way to achieve that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’m curious if something like https://wordpress.stackexchange.com/questions/53298/custom-post-type-url-rewriting would help out.

    We don’t have anything specific for settings inside CPTUI for this, as it’s more custom permalink creation than is possible with just register_post_type itself, outside of the slug/”with front” parts that are part of that function’s arguments.

    Hope this helps

    Thread Starter Chris

    (@osiak)

    My bad. I have put /products/books/ in the customer rewrite slug field instead of products/books. When removing the slashes at the beginning and end it works well.

    However, now I’m getting 404 errors on any regular page that has a parent of products, eg. mysite.com/products/bicycles.

    • This reply was modified 3 years, 2 months ago by Chris.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure the exact cause of that last part, other than just assuming that the mixing of all these parts is making WordPress not sure what it’s supposed to be querying for exactly. I’m curious if the insertion of “products” on your “books” post types is now making it think that “bicycles” is either its own post type or something else. Seeing as, if I’m reading everything correctly, you have a PAGE named “products”, and are also inserting “/products/” before the BOOKS post type.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add custom permalink prefix’ is closed to new replies.