use this function for unique post slug
function regenerate_post_permalink($post_type = 'post') {
global $wpdb;
$myrows = $wpdb->get_results("SELECT id, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type='$post_type' ");
$counter = 0;
foreach ($myrows as $pid) :
$post_title = regenerate_post_clear_diacritics($pid->post_title);
$post_title = sanitize_title_with_dashes($post_title);
$new_slug = wp_unique_post_slug($post_title, $pid->id, 'publish', $post_type, 0);
$sql = "UPDATE $wpdb->posts SET post_name = '" . $new_slug . "' WHERE ID = $pid->id";
$wpdb->query($sql);
$counter++;
endforeach;
return $counter;
}
More information – https://denis-creative.com/peregeneracziya-permalinkov-slagov-massovoe-izmenenie-chpu-na-sajte-wordpress/
]]>For cyrilic symbols use this table:
$table = array( 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', '?' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', '?' => 'YE', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'Y', '?' => 'I', '?' => 'YI', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'CZ', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'SHH', 'Ь' => '', 'Ъ' => '', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', '?' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', '?' => 'ye', 'ж' => 'zh', 'з' => 'z', 'и' => 'y', '?' => 'i', '?' => 'yi', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'cz', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shh', 'ь' => '', 'ъ' => '', 'ю' => 'yu', 'я' => 'ya', 'Ы' => 'Y', 'Э' => 'E', 'ы' => 'y', 'э' => 'e', '?' => '', '?' => '' );
So, I created a few pages and renamed them with the plugin and it was perfect, and then I started working on one of the pages. I decided instead of designing the other pages from scratch, I just decided to clone the designed page and just redo the slugs on the cloned pages. I deleted the old pages and I went into the plugin settings and deleted the permalinks from there so that I can rename the new cloned pages with the pages I named in the beginning. But, it won’t work. And I think it’s because I technically already named other pages with that slug. But I deleted the old pages with the slug, so I don’t know why it won’t work anymore. Every time I delete the plug and regenerate it with the new one, it jumps back to a default slug.
]]>Is it possible to add some wild-card generator for this plugin?
For example – I have 100’s titles “Photo” in 2 different blogs – standard WP slugs go as photo-1, photo-2 and so on. Same thing in another blog. When I try to export/import posts from blog-1 to blog-2 many posts are not imported because similar title/slug already exist in both blogs.
If plugin would have something like “wild card” that can randomly add few characters to slug to make it look like photo-abc123 it would be a great help not to loose posts during transition.
Thank you.
]]>Hi,
I just try to regenerate all my posts slug, and regenerated all by one single click. But when I check the posts slug, the old slug is still there and new generated slug is append to that.
Eg:
Old Slug : enhow-to-maximize-storagear
New Slug: enhow-to-maximize-storagear?????-??????-???-????-?????-???
can anybody please help on this.
Thank you,
]]>Hi,
I need your help Sandor Kovacs, i’m very angry about permalinks ?? i try a hundred solution but still not work %postname% permalinks.. I found your great plugin but it isn’t support Turkish characters ?? please help me about this.
Turkish characters ;
‘?’,’?’,’?’,’ü’,’ü’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’?’,’ü’,’ü’);
Across Latin characters;
‘s’,’s’,’i’,’u’,’u’,’o’,’o’,’c’,’c’,’s’,’s’,’i’,’g’,’g’,’i’,’o’,’o’,’c’,’c’,’u’,’u’);
Hey everyone,
If someone’s need to regenerate permalinks with cyrillic titles into latin permalinks (example: from post title “Привет” to URL “privet”), open file “regenerate-post-permalink.php” with notepad and replace code:
$table = array(
'à' => 'A', 'á' => 'A', '?' => 'A', '?' => 'A', '?' => 'A', '?' => 'A',
'?' => 'A', 'à' => 'a', 'á' => 'a', 'a' => 'a', '?' => 'a', '?' => 'a', '?' => 'a', '?' => 'ae',
'?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c',
'?' => 'D', '?' => 'd',
'è' => 'E', 'é' => 'E', 'ê' => 'E', '?' => 'E', 'ě' => 'E', 'è' => 'e',
'é' => 'e', 'ê' => 'e', '?' => 'e', 'ě' => 'e',
'ì' => 'I', 'í' => 'I', '?' => 'I', '?' => 'I', 'ì' => 'i', 'í' => 'i', '?' => 'i', '?' => 'i',
'?' => 'N', '?' => 'n',
'ò' => 'O', 'ó' => 'O', '?' => 'O', '?' => 'O', '?' => 'O', '?' => 'O',
'e' => 'o', 'ò' => 'o', 'ó' => 'o', '?' => 'o', '?' => 'o', '?' => 'o', '?' => 'o',
'?' => 'R', '?' => 'R', '?' => 'R', '?' => 'r', '?' => 'r',
'?' => 'S', '?' => 's', '?' => 'S', '?' => 's',
'?' => 'T', '?' => 't',
'ù' => 'U', 'ú' => 'U', '?' => 'U', 'ü' => 'U', 'ù' => 'u', 'ú' => 'u',
'?' => 'u', 'ü' => 'u',
'Y' => 'Y', '?' => 'y', 'y' => 'y', 'y' => 'y',
'?' => 'Z', '?' => 'z', '?' => 'Z', '?' => 'z',
'?' => 'Dj', '?' => 'dj', 'T' => 'B', '?' => 's', 't' => 'b',
);
With this code:
$table = array(
'à' => 'A', 'á' => 'A', '?' => 'A', '?' => 'A', '?' => 'A', '?' => 'A',
'?' => 'A', 'à' => 'a', 'á' => 'a', 'a' => 'a', '?' => 'a', '?' => 'a', '?' => 'a', '?' => 'ae',
'?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c',
'?' => 'D', '?' => 'd',
'è' => 'E', 'é' => 'E', 'ê' => 'E', '?' => 'E', 'ě' => 'E', 'è' => 'e',
'é' => 'e', 'ê' => 'e', '?' => 'e', 'ě' => 'e',
'ì' => 'I', 'í' => 'I', '?' => 'I', '?' => 'I', 'ì' => 'i', 'í' => 'i', '?' => 'i', '?' => 'i',
'?' => 'N', '?' => 'n',
'ò' => 'O', 'ó' => 'O', '?' => 'O', '?' => 'O', '?' => 'O', '?' => 'O',
'e' => 'o', 'ò' => 'o', 'ó' => 'o', '?' => 'o', '?' => 'o', '?' => 'o', '?' => 'o',
'?' => 'R', '?' => 'R', '?' => 'R', '?' => 'r', '?' => 'r',
'?' => 'S', '?' => 's', '?' => 'S', '?' => 's',
'?' => 'T', '?' => 't',
'ù' => 'U', 'ú' => 'U', '?' => 'U', 'ü' => 'U', 'ù' => 'u', 'ú' => 'u',
'?' => 'u', 'ü' => 'u',
'Y' => 'Y', '?' => 'y', 'y' => 'y', 'y' => 'y',
'?' => 'Z', '?' => 'z', '?' => 'Z', '?' => 'z',
'?' => 'Dj', '?' => 'dj', 'T' => 'B', '?' => 's', 't' => 'b',
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', '?' => 'G',
'?' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', '?' => 'YE',
'Ж' => 'ZH', 'З' => 'Z', '?' => 'Z', 'И' => 'I', 'Й' => 'J',
'?' => 'J', '?' => 'I', '?' => 'YI', 'К' => 'K', '?' => 'K',
'Л' => 'L', '?' => 'L', 'М' => 'M', 'Н' => 'N', '?' => 'N',
'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
'У' => 'U', '?' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'TS',
'Ч' => 'CH', '?' => 'DH', 'Ш' => 'SH', 'Щ' => 'SHH', 'Ъ' => '',
'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA',
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', '?' => 'g',
'?' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', '?' => 'ye',
'ж' => 'zh', 'з' => 'z', '?' => 'z', 'и' => 'i', 'й' => 'j',
'?' => 'j', '?' => 'i', '?' => 'yi', 'к' => 'k', '?' => 'k',
'л' => 'l', '?' => 'l', 'м' => 'm', 'н' => 'n', '?' => 'n',
'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
'у' => 'u', '?' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'ts',
'ч' => 'ch', '?' => 'dh', 'ш' => 'sh', 'щ' => 'shh', 'ъ' => '',
'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya'
);
After that save the php file, go to wordpress, choose post type, and regenerate it.
??
]]>Just ruined my site with 16K ads. NOT WORKING WITH DUPLICATE TITLES
]]>It does the job, but I ended up with a lot of error 404 with the older permalinks!
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>Does not fallow set permalink structure, all links generated had absolute path to their title slug.
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>I ran into an issue with this plugin where it was not testing for a unique slug. You could run something like this in the regenerate_post_permalink function:
$post_title = sanitize_title_with_dashes($post_title);
$new_slug = wp_unique_post_slug($post_title, $pid->id, 'publish', $post_type, $pid->post_parent);
And it would make sure the plugin is not repeated for that particular post type and would use WPs ownt title sanitization function to clean up the slug as well.
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>Hi,
This plugin is great.
But my language is Vietnamese using unicode. When i regenerate post permalinks it make to %abc%…
So it will be great for make it useful with unicode.
Thank all
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>Hi!
I downloaded the plugin because I imported more than 170.000 posts and I really need to rebuild the permalinks for all of them before going live.
Of course, it takes time, but the script breaks after 30 seconds. What should I do?
Thanks!
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>Hello
It would be possible to add support for Latin characters?
For example, replace “?, í, ?” (etc.) by “c, i, i”
Maybe include it as an option within the plugin?
Thank you!
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>Hello,
Thanks for taking time and releasing this as a plugin.
I have a question, does this plugin handles the case of duplicate titles?
Thank you
https://www.ads-software.com/plugins/regenerate-post-permalinks/
]]>