Many times, you would like to remove the custom post type slug from urls. You don’t want frontend users to see you custom post type slug and to know you are using one. I kept looking for solutions, modified rewrite rules and did lots of things finally found a very easier solution. This solution works for hierarchical posts and non-hierarchical both. It also removes parent slug from hierarchical posts. I hope this would help you guys. Here is the code.
The above code snippet will be put into your functions.php and it will remove slugs from all post urls. So where ever in the template you are displaying the_permalink() . But clicking those links you will get a 404, page not found if you don’t set the right query vars which are set in code given below:
So adding the above two snippets to funtions.php will remove custom post type slugs from urls. But last thing is:
don’t forget to replace your_custompost_type_slug in above code with your custom post type slug. Happy coding!
courtesy:<a href=”http://ryansechrest.com/2013/04/remove-post-type-slug-in-custom-post-type-url-and-move-subpages-to-website-root-in-wordpress/”>Ryan Sechrest. </a>