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

WordPress Development Asked by Joboy2212 on November 14, 2020

I’ve been trying to add a subdirectory to my blog post’s permalink for example

However, this is affecting the other post types that I’ve created using Pods such as is now

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.

One Answer

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

Answered by Tom J Nowell on November 14, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP