Hello,
Because after publishing the post, there is no parameter post_type in the URL and the code will not work correctly. After publishing the post, there is the post ID in the URL and you can get the post type by using the WordPress function get_post_type().
For example:
$prefix = '';
$post_type = $_GET['post_type'];
$taxonomy = '';
$placehold = '';
if( empty( $post_type ) ) {
$post_id = null;
if ( isset( $_GET['post'] ) ) {
$post_id = intval( $_GET['post'] );
} elseif ( isset( $_POST['post_ID'] ) ) {
$post_id = intval( $_POST['post_ID'] );
}
$post_type = get_post_type( $post_id );
}