Remove Custom Post Type Slug from Permalink

Feb 12, 2014 by Mark Ward in Quick Tips, Web Design, WordPress

There are times that you want to stray from the regular permalink structure that WordPress applies to your custom post types.  For a recent project I was needing to remove the CPT slug from the permalink, so a page url like  “/events/some-event-slug/” would have the permalink of “/some-event-slug/.”  At first glance this doesn’t seem to be that difficult to accomplish, but then you start looking through the forums for a solution and come back with several different “solutions” and none of which work for you. Then there are time you find a script that just works, and that is what I am sharing with you.

Thanks WordPress VIP for posting a solution.

Just paste the following code in your functions.php file and replace “your_post_type” with the slug of the post type you wish to drop the slug from.

When that’s done be sure and update permalinks. That’s it.

See original post here: