0

This question was already asked million times, but I do have an issue with the very simple solution of adding /blog/%postname% to the permalink structure.

I've installed several custom post types an d I use the Custom Post Type Permalinks plugin to have a permalink structure of example.com/cpt_name/parent_cat/child_cat/postname. This works really well. Now I wanted to add /blog/ to all my blog posts (default WordPress Post post type). So I added /blog/%postname% to my permalink structure and it works well. That was pretty simple...

BUT I now checked the permalink for my custom post types. They are example.com/blog/cpt_name/parent_cat/child_cat/postname now, which is definitely not what I waned... Do you know a solution that should work in this case?

-1

You can do this by adding this line of code to your Register_post_type $args Function array:

$args array

'with_front' => false,

this will remove the blog from the front of the CPT that you add this line.

Remember to flush permalinks after you add it and save.

from the codex:

'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.

you can see further reference here: https://codex.wordpress.org/Function_Reference/register_post_type

or just ask!

3
  • I just saw, that blog is also present on author archive pages. How can I remove it from there? The current url is: example.com/blog/author/{author name} – Sam Feb 22 '17 at 17:20
  • That's not the normal behavior. Have you tried removing the other plugins that you originally set up? You said in your original question: "So I added /blog/%postname% to my permalink structure and it works well. That was pretty simple." maybe what you did there affected more than you were expecting? – rudtek Feb 22 '17 at 21:01
  • It actually needs to be added into the rewrite key as an array: 'rewrite' => array( 'with_front' => false ), – Zach Russell Oct 6 '17 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.