Change the slug of post type using custom code

There is a function called wp_unique_post_slug which is called whenever you save a post. This function contains a filter of the same name that you can use to modify the slug, depending on, for instance, the post type. This example will prepend the slug with the post type, so you can see from the slug which type a post belongs to:

add_filter ('wp_unique_post_slug','wpse420126_change_slug', 10, 6);

function wpse420126_change_slug ($slug, $post_id, $post_status, $post_type, $post_parent, $original_slug) {
  return $post_type . '-' . $slug;
  }

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduseduedusedusedusedueduedu