Forums › Forums › Remove CPT base › Problem with url incrementation (post-type-1-1-1) › Reply To: Problem with url incrementation (post-type-1-1-1)
Hello,
every post should have unique post_name, this is how WordPress works.
Of course, there are many ways how to get around it, but it depends on specific setup.
Maximum what I can do is to create checkbox for disabling unique slugs, but it can cause many problems for many users.
The thing is, that in general, when you need so many same post_names, you’re doing something wrong. For example in your case I recommend to use custom endpoint instead of creating subpost for every post.
https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint
Put this in you functions.php
add_filter( 'query_vars', 'add_query_vars' );
function add_query_vars( $vars ){
$vars[] = 'tarifs';
return $vars;
}
add_rewrite_endpoint( 'tarifs', EP_PERMALINK );
then in single-city.php use $wp_query->query['tarifs']