I've build several post types - one of them called Manuals.
When I see the URL is says hidden link
I would like the URL instead to be /ergonomics-risk-assessment/ - ergo to loose /manual/
I've opened "Edit Post Type" under "Options" and tried to rewrite it via custom URL (and keep the field empty) but it doesn't work.
What do I do?
Hi,
Thank you for contacting us and I'd be happy to assist.
To remove the post type's slug from the URL of a post type, you can include a forward slash '/' in the "Use a custom URL format" field, as shown in the screenshot.
After making this change, please flush WordPress rewrite rules by clicking the "Save Changes" button at WP Admin -> Settings -> Permalinks and then check that post's URLs.
I hope this helps and please let me know if you need further assistance.
regards,
Waqar
Hi Waqar.
Thank you for your reply.
I have tried with '/' and it works on this post type - but when I do it on other post types I have built all the links tells me that the pages are not found any more.
I have now reset all post types back to wordpress standards and links works again. What do I do wrong?
Best regards
Kristen
Hi again Waqar.
Just to make sure I followed your instructions in your earlier reply - also about clicking save button at WP Admin -> Settings -> Permalinks and then check that post's URLs.
I tried it again tonight with only post type Manuals and it ended up in a fail.
Normally the topmenu "Ergonomics" points to this URL: hidden link
But when I tried '/' (only using the / in the "Use a custom URL format" field) the menu now showed this URL:
hidden link
That is the same URL as the French ergonomics page here:
hidden link
Thanks for writing back.
What you're experiencing is the limitation of how WordPress permalinks and slugs handling logic works.
It is a good/safe practice to keep the post-type slug (e.g. /manual/ ) in the URL so that the permalinks rewrite rules know exactly which post-type slugs to look for.
e.g.
website.com/{post-type-slug}/{individual-post-slug}
But, when we skip the {post-type-slug} part, the rewrite rules try to find the nearest possible slug from all post types, including the default post types like regular pages and posts.
( priority is given to custom post-type slugs over the slugs of the regular pages, which is exactly what you experienced in the case of the 'Ergonomics' page )
To avoid conflicts like these between the similar or same slugs from different post/page items on the website, I'll recommend keeping the {post-type-slug} part of the custom post links.
I hope this makes sense and please let me know if you have any follow-up questions.
Hello again Waqar.
If I understand this correctly then I can't remove /manual/ from the URL?
That will be a true dissapointment from the customer if that is so.
Best regards Kristen
Unfortunately, there is no straightforward way to achieve this.
You'll have to rely on some custom rewrite rule workarounds, as discussed in the following resource:
hidden link
https://wordpress.stackexchange.com/questions/203951/remove-slug-from-custom-post-type-post-urls