Skip Navigation

[Resolved] Removing custom post type slug from url

This thread is resolved. Here is a description of the problem and solution.

Problem:
Is it possible to remove the slug of the custom post type in the URLs for individual custom posts?

Solution:
No. It is not possible with WordPress without writing custom rewrite rules.

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#611650

I have currently working solution where I have custom post type which has two post types as childs and solution is working fine. I wish to remove slug from url from parent post type (domain/SLUG/post). Can this be done?

If not, I was wondering can this be done by moving these custom post types childs to normal pages? (Pages have no additional slugs in url). We have encountered earlier a problem in similar situation, where custom post childs of pages converted from custom posts to pages when saving the page.

#611760

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

WordPress does not support this, it explicitly requires that custom posts use a slug in their URL. By default it is the slug of the custom post type, but it can be changed to whatever URL-appropriate text you like (in the options section when editing your custom post type).

It requires the slug to avoid possible ambiguity resolving URLs, e.g. how else would it know whether site.com/first referred to a page called "first" or to a custom post type called "first".

Types simply adopts these WordPress requirements.

You can override them at your own risk by a custom code solution, such as is described here: https://wordpress.stackexchange.com/a/204210/35739

Types lets you create post relationships between posts of different types, so you could make the parent post type "pages", and then you could publish parent posts without a slug in the URL.