最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - How to add a sub directory to WordPress single posts without affecting other post types?

programmeradmin1浏览0评论

I've been trying to add a subdirectory to my blog post's permalink for example domain/blog/post-slug/

However, this is affecting the other post types that I've created using Pods such as domain/knowledgebase/ is now domain/blog/knowledgebase/

I would appreciate anyone helping me solve this problem. I still just want a blog as a subdirectory for my posts but I need the other post types not affected by that change.

I've been trying to add a subdirectory to my blog post's permalink for example domain/blog/post-slug/

However, this is affecting the other post types that I've created using Pods such as domain/knowledgebase/ is now domain/blog/knowledgebase/

I would appreciate anyone helping me solve this problem. I still just want a blog as a subdirectory for my posts but I need the other post types not affected by that change.

Share Improve this question asked Oct 21, 2020 at 12:52 Joboy2212Joboy2212 13 bronze badges 2
  • What method did you use to add the /blog/ prefix? There might be a super easy fix for this but it all assumes you used one specific method of doing it – Tom J Nowell Commented Oct 21, 2020 at 13:20
  • I didn't spot that you mentioned you were using Pods, I left an answer below but that's for generic WP, by using Pods you've restricted yourself to those familiar with Pods, so I don't know if the equivalent option is available via the Pods framework. As an aside, you can generate CPT's by just filling out a form on a generator site, you don't need a plugin to create them for you – Tom J Nowell Commented Oct 21, 2020 at 13:46
Add a comment  | 

1 Answer 1

Reset to default 1

If we look at the register_post_type documentation, in the rewrite option, there is a sub-option that controls this:

'with_front' => bool Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true

So something like this:

    ...
    'rewrite' => [ 'with_front' => false ],
    ...

More information on register_post_type rewrite options

发布评论

评论列表(0)

  1. 暂无评论