Maarten Wolfsen Maarten Wolfsen - 4 months ago 4x
PHP Question

URL showing unnecessary post types in WordPress

My website, let's call it, has a few Post Types:

- Post (the default post type) with the slug 'blog'
- Cases with the slug 'cases'
- Klanten with the slug 'klanten' (Dutch word for clients)

When I go to the blog page, the url shows like this:

And when I then navigate to a blog post, it shows this:

This is also good.

But now the problem. When I go the the cases page, the URL shows like this:

This is fine, but when I select a case, the URL shows like this:

Ofcourse, I want this URL to be:


Try to call register_post_type() param 'rewrite' with additional argument 'with_front' => false

From Codex documentation: '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

$args = array(
    /*other args*/
    'rewrite' => array('slug' => 'cases', 'with_front' => false),
    /*other args*/
register_post_type( 'cases', $args );