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'
    ) );
  • 1
    What value are you using for DB_COLLATE?
    – fuxia
    Dec 6 '14 at 15:14
  • 1
    I use the Ðð chars in my language (Icelandic) and by using the correct collation (as @toscho suggests) you can fix the ordering. I use utf8_icelandic_ci and I guess there exists something similar for your language?
    – birgire
    Dec 6 '14 at 15:23
  • 2
    Use utf8_unicode_ci, that covers most languages. Never use utf8_general_ci.
    – fuxia
    Dec 6 '14 at 16:20
  • So you guy think this is a DB issuse, intrestin ;) - didnt think about that...
    – Sagive SEO
    Dec 6 '14 at 16:38

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:


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


If Wordpress is installed in your language, that shouldn't be a problem.

You are missing the order parameter:

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

Hope this helps, always best to check the codex

  • I did check the codex, 'order' has default value for DESC so it is not needed. Either way, if i put it in everything is the same and it doesnt address the issue. But thank you for your time
    – Marko
    Dec 6 '14 at 16:48
  • yep, tought your having a simpler issuse but its seems this a problem with mixing english with other language ;( - does the post slug aka orderby=>name - isnt applicable? What characters apear in the slug? - in any case, sorry i could help further -trying to research this more...
    – Sagive SEO
    Dec 6 '14 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.