0
votes

I've created a custom post-type in my theme, named portfolio. I've set the permalinks for my blog to be /blog/post-name, and now by default my portfolio posts are /blog/portfolio/post-name is there any way to take the blog part out of the portfolio url?

1

1 Answers

0
votes

One way would be using WP_Rewrite but there is no way of overriding the base path (/blog) as it's the RewriteBase /blog/ rule in the generated .htaccess file. So either remove that base path and use WP_Rewrite to add it back or manually edit .htaccess and rewrite it, before the RewriteBase directive:

...
RewriteBase /
RewriteRule ^/blog/portfolio/(.*)$ http://example.com/portfolio/$1 [R=301,L]
RewriteBase /blog/
...

But I would not encourage this as WordPress will overwrite your changes the next time you submit the permalinks admin form.

So long story short: remove that /blog/ basepath. If you don't know how to use WP_Rewrite then you could register a new custom post type named "Blog Post" with blog for the slug parameter and use those instead of the default "Posts".