Title: Error: Permalink Already in Use!
Last modified: January 1, 2024

---

# Error: Permalink Already in Use!

 *  Resolved [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * (@suffianshakoor)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/)
 * Hi
   Is there a way that we can prevent the admin for creating duplicate URLsExample:
 * If there is already a URL with
 * [https://example.com/job/testing](https://example.com/job/testing)
 * And admin wants to create a new job with same URL by using [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
   
   Except for showing (**Permalink is already in use, please select another one!**)
   Dont allow to create the same URL

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17311518)
 * Hi [@suffianshakoor](https://wordpress.org/support/users/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:
 *     ```wp-block-code
       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);
       ```
   
 *  Thread Starter [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * (@suffianshakoor)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17311823)
 * [@mbis](https://wordpress.org/support/users/mbis/) Thank you for sharing the 
   code snippet. I’ve implemented it as suggested, but unfortunately, it doesn’t
   seem to be addressing the issue of preventing duplicate URLs. The default permalink
   is being forced to be unique as expected. But after the creation of new post 
   We can still change the URLs from Permalink Manager Lite and make the URLs as
   same as already exists.
 * I wanted to reach out to see if there might be additional steps or modifications
   needed to achieve the desired outcome. If there are any alternative approaches
   or if there have been updates since the provided solution, I would greatly appreciate
   any further guidance you can provide.
 * Thank you
    -  This reply was modified 2 years, 5 months ago by [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/).
 *  Thread Starter [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * (@suffianshakoor)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17311971)
 * I am asking these changes because i have created two jobs with the same URLs 
   with the help of permalinks manager lite. I have set one job as private and the
   other as published. However, the private job’s URL is displaying instead of the
   published one. Even when you open the page in a private window, it shows a 404
   error. It might be possible that the system does not grant access to either of
   them or only allows access to the private one.
   **URL : **[https://www.placedrecruitment.com.au/job/group-chef-director-of-culinary-to-220-s-large-complex-business/](https://www.placedrecruitment.com.au/job/group-chef-director-of-culinary-to-220-s-large-complex-business/)**
   Screenshot :** [https://www.awesomescreenshot.com/image/45151917?key=e0b857a6843e3409c10c799ae5b8f729](https://www.awesomescreenshot.com/image/45151917?key=e0b857a6843e3409c10c799ae5b8f729)
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17312506)
 * Hi [@suffianshakoor](https://wordpress.org/support/users/suffianshakoor/),
 * According to the debug data, it seems that Permalink Manager ignores that “private”
   job:
 * [https://www.placedrecruitment.com.au/job/group-chef-director-of-culinary-to-220-s-large-complex-business/?debug_url](https://www.placedrecruitment.com.au/job/group-chef-director-of-culinary-to-220-s-large-complex-business/?debug_url)
 * If this is the case, the plugin should load the second published job as long 
   as it uses the same custom permalink (_job/group-chef-director-of-culinary-to-
   220-s-large-complex-business_).
 * Could you check if the custom permalink is saved for the second job in the “Debug”
   section (the first textarea field):
 * ![](https://i0.wp.com/permalinkmanager.pro/wp-content/uploads/2019/03/Debug-section-
   2048x1093.jpg?resize=2048%2C1093&ssl=1)
 *  Thread Starter [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * (@suffianshakoor)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17312600)
 * [@mbis](https://wordpress.org/support/users/mbis/) As you can see the URL is 
   there two times : 
   _job/group-chef-director-of-culinary-to-220-s-large-complex-
   business_[https://www.awesomescreenshot.com/image/45156920?key=9913b68c32a69f10c6b9f94b6c918950](https://www.awesomescreenshot.com/image/45156920?key=9913b68c32a69f10c6b9f94b6c918950)
 * ![](https://www.awesomescreenshot.com/image/45156920?key=9913b68c32a69f10c6b9f94b6c918950)
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17313715)
 * Hi [@suffianshakoor](https://wordpress.org/support/users/suffianshakoor/),
 * Could you try to use this code snippet instead?
 *     ```wp-block-code
       function pm_ignore_private_posts( $excluded, $element_object, $old_query, $pm_query ) {
       	if ( ! empty( $element_object->post_status ) && $element_object->post_status == 'private' ) {
       		$excluded = $element_object->ID;
       	}
   
       	return $excluded;
       }
       add_filter( 'permalink_manager_excluded_element_id', 'pm_ignore_private_posts', 50, 4 );
       ```
   
 *  Thread Starter [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * (@suffianshakoor)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17317392)
 * [@mbis](https://wordpress.org/support/users/mbis/) The issue we previously reported
   has been successfully resolved after implementing the provided code. 
   I appreciate
   your prompt attention to this matter and the collaborative effort in resolving
   the issue.Thank you for your assistance.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Error: Permalink Already in Use!’ is closed to new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Suffian Shakoor](https://wordpress.org/support/users/suffianshakoor/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/error-permalink-already-in-use/#post-17317392)
 * Status: resolved