Remove CPT slug from URL

This question has been asked so many times, and i have viewed every answer in this meta, and outside.

Still none are functioning in WordPress 4.9.5 (latest version).
The enhancement asked 3 years ago is still waiting: https://core.trac.wordpress.org/ticket/34136#ticket

How to remove the Custom Post Type slug name from the url, without creating issue to previous posts or pages?

I’ve tried the following solutions:
https://wordpress.stackexchange.com/a/204210 – 404 page
https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/ – 404 page
http://www.codeinhouse.com/remove-slug-from-custom-post-type-in-wordpress/ – 404 page

1 Answer
1

Change permstruct for your CPT.

add_action( 'init', function() {
    add_permastruct( 'tvshow', '/custom_home_page/%tvshow%');
}, 11);

However, this is a complex question and can involve different steps to make it work in different ways.

P/S/
don’t forget to flush url rules.

Leave a Comment