Still have problem with slug results on Reset/Regenerate
-
Hi @mbis
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.png2) 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.pngThis 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
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Still have problem with slug results on Reset/Regenerate’ is closed to new replies.