Stop WordPress from reserving slugs for media items?

Thank you for the response everyone. I played around with macemmek’s solution and I think it led me to an even better solution:

add_filter( 'wp_unique_post_slug_is_bad_attachment_slug', '__return_true' );

That is all that is needed. This will automatically ‘skip’ the default assigned slug on any attachment. So an attachment that might normally get the slug “services” will now get the slug “services-2”.

Leave a Comment