I want to sort posts by alphabet in local language (croatian language).

So letter Đ should come after D but now it goes in the end, after Z.
Some letters (like Č and Ć) should come after C, but currently WordPress is sorting them like they all are under C.

I am using localized WordPress version (4.0.1–hr) and the query for fetching is

$query = new WP_Query( array( 
    'category_name' => $slug, 
    'paged' => get_query_var('paged'),
    'posts_per_page' => 20,
    'orderby' => 'title'
    ) );

2 Answers
2

I managed to make it work:

In wpconfig.php file I set

define('DB_COLLATE', 'utf8_croatian_ci');

Do an SQL query on database in PhpMyadmin with:

ALTER TABLE wp_posts CONVERT TO CHARACTER SET utf8 COLLATE utf8_croatian_ci

I tried setting with utf8_unicode_ci first, sorting was slightly better but not quite accurate.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *