# Latin Slugs for Cyrillic, Greek and Other Scripts

> Turns post and term titles written in Cyrillic, Greek, Georgian or other non-Latin scripts into readable Latin URL slugs (for example "Привет мир" becomes privet-mir) instead of long percent-encoded addresses.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: slugs, transliteration, urls
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/i18n-transliterate-slugs/

## Code

```php
add_filter( 'sanitize_title', function ( $title, $raw_title, $context ) {
    if ( 'save' !== $context || '' === $title || ! preg_match( '/[^\x00-\x7F]/', $title ) ) {
        return $title;
    }

    static $table = null;

    if ( class_exists( 'Transliterator' ) ) {
        $tr = Transliterator::create( 'Any-Latin; Latin-ASCII; Lower()' );
        if ( $tr ) {
            $out = $tr->transliterate( $title );
            if ( is_string( $out ) && '' !== $out ) {
                return $out;
            }
        }
    }

    if ( null === $table ) {
        $table = array(
            'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ґ' => 'g', 'д' => 'd', 'е' => 'e', 'є' => 'ye', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'і' => 'i', 'ї' => 'yi', 'й' => 'y',
            'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'ts', 'ч' => 'ch',
            'ш' => 'sh', 'щ' => 'shch', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
            'α' => 'a', 'β' => 'v', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'i', 'θ' => 'th', 'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => 'x',
            'ο' => 'o', 'π' => 'p', 'ρ' => 'r', 'σ' => 's', 'ς' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'ch', 'ψ' => 'ps', 'ω' => 'o',
            'ά' => 'a', 'έ' => 'e', 'ή' => 'i', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ώ' => 'o',
        );
    }

    return strtr( mb_strtolower( $title, 'UTF-8' ), $table );
}, 9, 3 );
```

## Notes

Uses PHP's intl Transliterator when available and a built-in Cyrillic/Greek table otherwise. Existing slugs are not changed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Latin Slugs for Cyrillic, Greek and Other Scripts" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
