Hi @suffianshakoor
Unfortunately, there is no out-of-box solution available. You can however try to use the below code snippet and control how the new custom permalinks are generated.
After you implement it, whenever a new custom permalink is generated for a new item, the default permalink for it will be forced to be unique:
function pm_unique_permalinks( $default_uri, $native_slug, $element, $post_name, $native_uri ) {
global $permalink_manager_uris;
// Ignore native permalinks
if ( $native_uri ) {
return $default_uri;
}
// Store all the custom permalinks in a separate variable
$uris = $permalink_manager_uris;
// Exclude this element
if ( ! empty( $element->ID ) && ! empty( $uris[ $element->ID ] ) ) {
unset( $uris[ $element->ID ] );
} else if ( ! empty( $element->term_id ) && ! empty( $uris[ $element->term_id ] ) ) {
unset( $uris["tax-{$element->term_id}"] );
}
do {
$duplicates_ids = array_keys( $uris, $default_uri );
$duplicates_ids_count = count( $duplicates_ids );
if ( ! empty( $duplicates_ids_count ) ) {
preg_match( '/(.+?)(?:-([\d]+))?(\.[^\.]+$|$)/', $default_uri, $parts );
$index = ( ! empty( $parts[2] ) ) ? $parts[2] + 1 : 2;
$default_uri = preg_replace( '/(.+?)(?:-([\d]+))?(\.[^\.]+$|$)/', '$1-' . $index . '$3', $default_uri );
}
} while ( $duplicates_ids_count > 0 );
return $default_uri;
}
add_filter('permalink_manager_filter_default_post_uri', 'pm_unique_permalinks', 999, 5);