Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you run custom scripts to manipulate the database, why don't you change the slug as well? I'm using a nice function for that:</p> <pre><code>function url_slug($str, $options = array()) { // Make sure string is in UTF-8 and strip invalid UTF-8 characters $str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings()); $defaults = array( 'delimiter' =&gt; '-', 'limit' =&gt; 100, 'lowercase' =&gt; true, 'replacements' =&gt; array(), 'transliterate' =&gt; false, ); // Merge options $options = array_merge($defaults, $options); $char_map = array( // Latin 'À' =&gt; 'A', 'Á' =&gt; 'A', 'Â' =&gt; 'A', 'Ã' =&gt; 'A', 'Ä' =&gt; 'A', 'Å' =&gt; 'A', 'Æ' =&gt; 'AE', 'Ç' =&gt; 'C', 'È' =&gt; 'E', 'É' =&gt; 'E', 'Ê' =&gt; 'E', 'Ë' =&gt; 'E', 'Ì' =&gt; 'I', 'Í' =&gt; 'I', 'Î' =&gt; 'I', 'Ï' =&gt; 'I', 'Ð' =&gt; 'D', 'Ñ' =&gt; 'N', 'Ò' =&gt; 'O', 'Ó' =&gt; 'O', 'Ô' =&gt; 'O', 'Õ' =&gt; 'O', 'Ö' =&gt; 'O', 'Ő' =&gt; 'O', 'Ø' =&gt; 'O', 'Ù' =&gt; 'U', 'Ú' =&gt; 'U', 'Û' =&gt; 'U', 'Ü' =&gt; 'U', 'Ű' =&gt; 'U', 'Ý' =&gt; 'Y', 'Þ' =&gt; 'TH', 'ß' =&gt; 'ss', 'à' =&gt; 'a', 'á' =&gt; 'a', 'â' =&gt; 'a', 'ã' =&gt; 'a', 'ä' =&gt; 'a', 'å' =&gt; 'a', 'æ' =&gt; 'ae', 'ç' =&gt; 'c', 'è' =&gt; 'e', 'é' =&gt; 'e', 'ê' =&gt; 'e', 'ë' =&gt; 'e', 'ì' =&gt; 'i', 'í' =&gt; 'i', 'î' =&gt; 'i', 'ï' =&gt; 'i', 'ð' =&gt; 'd', 'ñ' =&gt; 'n', 'ò' =&gt; 'o', 'ó' =&gt; 'o', 'ô' =&gt; 'o', 'õ' =&gt; 'o', 'ö' =&gt; 'o', 'ő' =&gt; 'o', 'ø' =&gt; 'o', 'ù' =&gt; 'u', 'ú' =&gt; 'u', 'û' =&gt; 'u', 'ü' =&gt; 'u', 'ű' =&gt; 'u', 'ý' =&gt; 'y', 'þ' =&gt; 'th', 'ÿ' =&gt; 'y', // Latin symbols '©' =&gt; '(c)', // Greek 'Α' =&gt; 'A', 'Β' =&gt; 'B', 'Γ' =&gt; 'G', 'Δ' =&gt; 'D', 'Ε' =&gt; 'E', 'Ζ' =&gt; 'Z', 'Η' =&gt; 'H', 'Θ' =&gt; '8', 'Ι' =&gt; 'I', 'Κ' =&gt; 'K', 'Λ' =&gt; 'L', 'Μ' =&gt; 'M', 'Ν' =&gt; 'N', 'Ξ' =&gt; '3', 'Ο' =&gt; 'O', 'Π' =&gt; 'P', 'Ρ' =&gt; 'R', 'Σ' =&gt; 'S', 'Τ' =&gt; 'T', 'Υ' =&gt; 'Y', 'Φ' =&gt; 'F', 'Χ' =&gt; 'X', 'Ψ' =&gt; 'PS', 'Ω' =&gt; 'W', 'Ά' =&gt; 'A', 'Έ' =&gt; 'E', 'Ί' =&gt; 'I', 'Ό' =&gt; 'O', 'Ύ' =&gt; 'Y', 'Ή' =&gt; 'H', 'Ώ' =&gt; 'W', 'Ϊ' =&gt; 'I', 'Ϋ' =&gt; 'Y', 'α' =&gt; 'a', 'β' =&gt; 'b', 'γ' =&gt; 'g', 'δ' =&gt; 'd', 'ε' =&gt; 'e', 'ζ' =&gt; 'z', 'η' =&gt; 'h', 'θ' =&gt; '8', 'ι' =&gt; 'i', 'κ' =&gt; 'k', 'λ' =&gt; 'l', 'μ' =&gt; 'm', 'ν' =&gt; 'n', 'ξ' =&gt; '3', 'ο' =&gt; 'o', 'π' =&gt; 'p', 'ρ' =&gt; 'r', 'σ' =&gt; 's', 'τ' =&gt; 't', 'υ' =&gt; 'y', 'φ' =&gt; 'f', 'χ' =&gt; 'x', 'ψ' =&gt; 'ps', 'ω' =&gt; 'w', 'ά' =&gt; 'a', 'έ' =&gt; 'e', 'ί' =&gt; 'i', 'ό' =&gt; 'o', 'ύ' =&gt; 'y', 'ή' =&gt; 'h', 'ώ' =&gt; 'w', 'ς' =&gt; 's', 'ϊ' =&gt; 'i', 'ΰ' =&gt; 'y', 'ϋ' =&gt; 'y', 'ΐ' =&gt; 'i', // Turkish 'Ş' =&gt; 'S', 'İ' =&gt; 'I', 'Ç' =&gt; 'C', 'Ü' =&gt; 'U', 'Ö' =&gt; 'O', 'Ğ' =&gt; 'G', 'ş' =&gt; 's', 'ı' =&gt; 'i', 'ç' =&gt; 'c', 'ü' =&gt; 'u', 'ö' =&gt; 'o', 'ğ' =&gt; 'g', // Russian 'А' =&gt; 'A', 'Б' =&gt; 'B', 'В' =&gt; 'V', 'Г' =&gt; 'G', 'Д' =&gt; 'D', 'Е' =&gt; 'E', 'Ё' =&gt; 'Yo', 'Ж' =&gt; 'Zh', 'З' =&gt; 'Z', 'И' =&gt; 'I', 'Й' =&gt; 'J', 'К' =&gt; 'K', 'Л' =&gt; 'L', 'М' =&gt; 'M', 'Н' =&gt; 'N', 'О' =&gt; 'O', 'П' =&gt; 'P', 'Р' =&gt; 'R', 'С' =&gt; 'S', 'Т' =&gt; 'T', 'У' =&gt; 'U', 'Ф' =&gt; 'F', 'Х' =&gt; 'H', 'Ц' =&gt; 'C', 'Ч' =&gt; 'Ch', 'Ш' =&gt; 'Sh', 'Щ' =&gt; 'Sh', 'Ъ' =&gt; '', 'Ы' =&gt; 'Y', 'Ь' =&gt; '', 'Э' =&gt; 'E', 'Ю' =&gt; 'Yu', 'Я' =&gt; 'Ya', 'а' =&gt; 'a', 'б' =&gt; 'b', 'в' =&gt; 'v', 'г' =&gt; 'g', 'д' =&gt; 'd', 'е' =&gt; 'e', 'ё' =&gt; 'yo', 'ж' =&gt; 'zh', 'з' =&gt; 'z', 'и' =&gt; 'i', 'й' =&gt; 'j', 'к' =&gt; 'k', 'л' =&gt; 'l', 'м' =&gt; 'm', 'н' =&gt; 'n', 'о' =&gt; 'o', 'п' =&gt; 'p', 'р' =&gt; 'r', 'с' =&gt; 's', 'т' =&gt; 't', 'у' =&gt; 'u', 'ф' =&gt; 'f', 'х' =&gt; 'h', 'ц' =&gt; 'c', 'ч' =&gt; 'ch', 'ш' =&gt; 'sh', 'щ' =&gt; 'sh', 'ъ' =&gt; '', 'ы' =&gt; 'y', 'ь' =&gt; '', 'э' =&gt; 'e', 'ю' =&gt; 'yu', 'я' =&gt; 'ya', // Ukrainian 'Є' =&gt; 'Ye', 'І' =&gt; 'I', 'Ї' =&gt; 'Yi', 'Ґ' =&gt; 'G', 'є' =&gt; 'ye', 'і' =&gt; 'i', 'ї' =&gt; 'yi', 'ґ' =&gt; 'g', // Czech 'Č' =&gt; 'C', 'Ď' =&gt; 'D', 'Ě' =&gt; 'E', 'Ň' =&gt; 'N', 'Ř' =&gt; 'R', 'Š' =&gt; 'S', 'Ť' =&gt; 'T', 'Ů' =&gt; 'U', 'Ž' =&gt; 'Z', 'č' =&gt; 'c', 'ď' =&gt; 'd', 'ě' =&gt; 'e', 'ň' =&gt; 'n', 'ř' =&gt; 'r', 'š' =&gt; 's', 'ť' =&gt; 't', 'ů' =&gt; 'u', 'ž' =&gt; 'z', // Polish 'Ą' =&gt; 'A', 'Ć' =&gt; 'C', 'Ę' =&gt; 'e', 'Ł' =&gt; 'L', 'Ń' =&gt; 'N', 'Ó' =&gt; 'o', 'Ś' =&gt; 'S', 'Ź' =&gt; 'Z', 'Ż' =&gt; 'Z', 'ą' =&gt; 'a', 'ć' =&gt; 'c', 'ę' =&gt; 'e', 'ł' =&gt; 'l', 'ń' =&gt; 'n', 'ó' =&gt; 'o', 'ś' =&gt; 's', 'ź' =&gt; 'z', 'ż' =&gt; 'z', // Latvian 'Ā' =&gt; 'A', 'Č' =&gt; 'C', 'Ē' =&gt; 'E', 'Ģ' =&gt; 'G', 'Ī' =&gt; 'i', 'Ķ' =&gt; 'k', 'Ļ' =&gt; 'L', 'Ņ' =&gt; 'N', 'Š' =&gt; 'S', 'Ū' =&gt; 'u', 'Ž' =&gt; 'Z', 'ā' =&gt; 'a', 'č' =&gt; 'c', 'ē' =&gt; 'e', 'ģ' =&gt; 'g', 'ī' =&gt; 'i', 'ķ' =&gt; 'k', 'ļ' =&gt; 'l', 'ņ' =&gt; 'n', 'š' =&gt; 's', 'ū' =&gt; 'u', 'ž' =&gt; 'z' ); // Make custom replacements $str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str); // Transliterate characters to ASCII if ($options['transliterate']) { $str = str_replace(array_keys($char_map), $char_map, $str); } // Replace non-alphanumeric characters with our delimiter $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str); // Remove duplicate delimiters $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str); // Truncate slug to max. characters $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8'); // Remove delimiter from ends $str = trim($str, $options['delimiter']); return $options['lowercase'] ? mb_strtolower($str, 'UTF-8') : $str; } </code></pre> <p>This function will only create the slug. I assume that you know how to create a script to get all records and change the field...?</p> <p><strong>UPDATE:</strong> you could try something like this (not tested):</p> <pre><code>$dbcnx = @mysql_connect('localhost', 'username', 'password'); if (!$dbcnx) { exit('&lt;p&gt;Unable to connect to the database server at this time.&lt;/p&gt;'); } if (!@mysql_select_db('database_name')) { exit('&lt;p&gt;Unable to locate the database at this time.&lt;/p&gt;'); } mysql_query("SET NAMES 'utf8'"); $q = "SELECT ID, post_title FROM wp_posts"; $r = mysql_query($q); while ($row = mysql_fetch_assoc($r)) { $slug = url_slug($row['post_title']); mysql_query("UPDATE wp_posts SET post_name='".$slug."' WHERE ID='".$row['ID']."'"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload