How To Remove Custom Post Slug From Url
Posted By Renu Yadav | 30-Apr-2018
Wordpress is good for writing blogs. Wordpress handles easily all blogs. If you changed the URL of the blog then there is no problem of redirection. Like you shared the blog on any site or any social site, after that if you changed the URL of the blog. Then there is no issue, WordPress redirect the old URL to new URL of the blog. Wordpress has the functionality to redirect your old blogs URL to new URL of the blog.
If you created the custom post type like Relevant Work. You write the posts under relevant work. When you go to the URL of the post. You see the post URL have relevant work slug. If you don't want to show relevant-work slug in your site URL. Like http://www.dummytext.com/relevant_work/internet-marketing-agency/.
Because of the above URL, you will get the issue on google ranking. So you have to remove relevant work slug from your URL.
Above code will add to the function.php file. If you want to add above code in another file Like custom-posttype.php. You can add this code to custom-posttype.php file. Before adding the code to file, you need to create custom-posttype.php file under inc folder. After creating the file for the custom post. Add the above code in custom-posttype.php file.
Now you can add this file to your function.php file. After adding above line in your function.php file. Your relevant work slug will remove from your site URL. After the removal of relevant work, now you can see this URL. http://www.dummytext.com/internet-marketing-agency/. Remove relevant work slug from URL will help your page ranking and also your URL will look good.Url is very important for every website. So WordPress provide so many facilities to the developer, they can change the URL of blogs.