Post-A: I have a post with slug ‘hello-world’ which is in published mode — default post of WordPress.
Post-B: I have create another post with same slug ‘hello-world’ which is in draft mode.
Now Post-A is showing following error.
“Oops! That page can’t be found.”
When Post-B is in draft mode why this conflict should occur. It should render Post-A which is in published mode.
Please also fix: Duplicate Slug error instead of appending -2 or give a warning message with same slug found and append “-2”.
]]>Everything works, no more duplicates now, and I have all your functions and filter placed, tested with single post, it works.
But i still have problem with Regenerate/Reset, as follows:
1) When selecting “Regenerate native slugs”, trim function doesn’t work on native slugs:
https://i.imgur.com/Qpjqo3B.png
2) When selecting “Use original URLs as custom permalinks”, trim function doesn’t work on native slugs, and New URI still have duplicates:
https://i.imgur.com/bnbyvi6.png
This is the code in my functions.php:
add_filter( 'permalink_manager_fix_uri_duplicates', '__return_true' );
function pm_trim_native_slug($slug) {
$max_words = 10;
$words = explode('-', $slug);
if(count($words) > $max_words) {
$slug = implode("-", array_slice($words, 0, $max_words));
}
return $slug;
}
add_filter('pre_wp_unique_post_slug', 'pm_trim_native_slug');
function pm_trim_custom_url($uri) {
$max_words = 10;
$new_title = '';
$slugs = explode('/', $uri);
for($i=0, $count = count($slugs); $i < $count; $i++) {
$slug = $slugs[$i];
$words = explode('-', $slug);
$new_title .= "/";
if(count($words) > $max_words) {
$new_title .= implode("-", array_slice($words, 0, $max_words));
} else {
$new_title .= $slug;
};
};
$new_title = trim($new_title, "/");
return $new_title;
};
add_filter( 'permalink_manager_filter_default_post_uri', 'pm_trim_custom_url', 99 );
add_filter( 'permalink_manager_filter_default_term_uri', 'pm_trim_custom_url', 99 );
thank you
]]>There is problem with duplicate slug and native slug on regenerate/reset, this is the screenshot:
The problem:
1) I selected “Regenerate native slug”, but instead, i got new custom URLs and native slugs remains the same.
2) The new generated URL doesn’t check for duplicates. so the link are all the same. i think the WordPress native slug always check for duplicates and adds number behind the URL if found. “wp_unique_post_slug” function i believe?
many thanks!
I am trying to setup a mobile store with woocommerce and I have some problems when I am creating categories.
For an example;
Category 1 :
Product Apple
Category 2 :
Product apple
and I want to display the URL like below
www.site.com/category-1/product-apple
www.site.com/category-2/product-apple
www.site.com/category-3/product-apple
But now when I am creating the second category called “product-apple” it says slug already exist.
How can I solve this problem ?
https://www.ads-software.com/plugins/woocommerce/
]]>Cars
-Honda (mysite.com/cars/honda)
-Toyota (mysite.com/cars/toyota)
Trucks
-Honda (mysite.com/trucks/honda)
-Toyota (mysite.com/trucks/toyota)
The system doesn’t allow that same category to exist amongst both product types, so you are forced with this inconceivably bad structure instead:
Cars
-Honda (mysite.com/cars/honda)
-Toyota (mysite.com/cars/toyota)
Trucks
-Honda (mysite.com/trucks/honda-2)
-Toyota (mysite.com/trucks/toyota-2)
…where the “-2” is forced to be appended to the second set of categories, even though they have nothing to do with the previous ones as seen in “/cars/”. What this does is make WordPress a mute point when creating either a multi-country site (mysite.com/us/ and mysite.com/canada/, where both have duplicate site-wide category structures that are canonized) and classifieds or ecommerce sites, where the webmaster is forced to put a “-2” or reword/add unnecessary words to a category slug just to appease the restriction that WordPress’ core puts forth.
I’ve been using WordPress for about 7 years, and this has not only never been fixed, but it never seems to be officially addressed or recognized. It’s just very discouraging, especially when you’re working on a huge project using WordPress, and suddenly get roadblocked because the software doesn’t allow you to perform the most fundamental action of having two identically named subcategories.
Having a storefront that looks like this simply doesn’t cut it:
mysite.com/new-cars/honda/accord/product-listing-here
mysite.com/used-cars/honda-2/accord-2/product-listing-here
nor does mysite.com/used-cars/used-honda/used-accord/product-listing-here, or any other reiteration or work-around involving the re-structuring of those URLs.
…and I think anyone would agree with that.
Really hoping this gets addressed as it is a major ongoing problem and there are numerous complaints about this on the forum over the past several years. Only a core update will fix this, so, only the dev team has the power to do anything about it.
Thanks for your attention and for understanding my frustration.
]]>Wondering if there’s a newer plugin that achieves Singular’s mission above, not just for posts but pages as well. I’ve seen some chatter that WP’s default addition of the extra suffix for similar named pages/posts is a huge downside when using it as a CMS.
]]>e.g. if tag doesn’t exist:
Parent category: Make Money, slug make-money
Child category: Internet Marketing, slug internet-marketing – which is correct and expected.
However if tag internet-marketing already exists, child category gets rewritten as internet-marketing-make-money
My workaround is to create the categories first as I want them, and then the tag slugs using a _ in place of a hyphen for the tags, e.g. category internet-marketing, tag internet_marketing. This however is not acceptable as the standard format for tags uses a hyphen.
]]>A little more information would be nice when things like this popup.
Specifically, I am trying to change the slug of a category to correct a typo (lkand instead of land) but each time I get this message.
Having dumped the database to a sql file I was able to locate a tag with the same slug and correct it, however a more verbose error message would have been a little more helpful.
]]>