If you will take a look to code of wp_unique_post_slug – you will see that…
- If its post type – attachment it will check only
ID
and
post_name
- If its hierarchical post type (page e.g.) – its
will check forpost_name
on same level (and for sure same
post_type
) - nav_menu_item also
hierarchical
post type but it
doesn’t require any slug so its skipped. - Else… it will check for
post_name
if samepost_type
Please take a look to the 4 item in my list. This is your case.
WP doesn’t care if you have such slug in same post_type with a post_status as Draft , Pending or AutoDraft… but let’s say if you have such a post with post_status Published or Trash
… well in this case you obliously (for me) will get dash + iterator number
in your slug.
if you will run query – may be you will see a different post statuses of the posts of non Uniq slug
SELECT COUNT( * ) AS `total` , `post_name` , CONCAT_WS(' and ', post_status) as Statuses
FROM `wp_posts`
WHERE `post_type` = 'motogp-2013'
GROUP BY CONCAT_WS(' and ', `post_name` ) `post_name`
ORDER BY `total` DESC
LIMIT 0 , 30
Still if you not lucky to find out the resone of slug you had want to generate isn’t generating… you can use a filter for non uniq slugs…
wp_unique_post_slug
it can have 7 arguments… ($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) whish you can use…
add_filter('wp_unique_post_slug', 'se_126293_wp_unique_post_slug',10,7);
function se_126293_wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug){
// do whatever you want with a slug, but whatch out
return $slug;
}
You can place this code to your theme’s functions.php
or plugin…