I also tried this:
function pg_slug_exists( $post_name, $post_type ) {
global $wpdb;
$exclude = false;
if ( isset( $_GET ) && isset( $_GET[ 'id' ] ) ) {
$exclude = " AND ID != '".$_GET[ 'id' ]."'";
}
if( $wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $post_name . "' AND post_type = '" . $post_type . "'".$exclude."", 'ARRAY_A' ) ) {
return true;
} else {
return false;
}
}
but no luck