wp_list_categories wrong sorting by name (6 posts)

  1. 2046
    Posted 5 years ago #

    look at this

    the yellow table shows the wp_list_categories list.
    Bold text are the arguments I run and the rest is the result.
    (here is a copy of the function)

    $sec_level_arg = array(
    'style' => 'none',
    'orderby' => 'name',
    'order' => 'ASC',
    'hide_empty' => '0',
    'depth' => '2',
    'taxonomy' => 'taxonomy',
    'echo' => '0',
    echo wp_list_categories($sec_level_arg);

    If you look at the output closer you realize that it isn't sorted by name. Here is the part of the output

    Všetaty u Mělníka
    Velika Gorica

    as you can see it isn't alphabetical in any way.

    It seams to me that this problem occurs only when I go deeper then 'depth' => '1',
    The depth one seams to be OK, but 2, 3 are mixed in this weird way.
    Plus, might be that the problem show up only for taxonomies(I have no proof if it does same thing for categories as well), but that's only my guess. If that's the truth then there is something wrong in WP core.

    any suggestions?

  2. Jack
    Posted 5 years ago #

    I have the same problem, using 3.1.2 and this code:


    The categories aren't loaded by name at all. If I use ID instead, it works ok, but ordering by name fails!

  3. 2046
    Posted 5 years ago #

    check if you don't use any language plugin, which was my problem.

    this city name took always the "C" position in the list, because sorting function runs before the language plugin.
    If the plugin parse the item before WP core sorting function all will be OK, but that isn't the case.

    hope it helps

  4. Jack
    Posted 5 years ago #

    I don't use a language plugin and the order remains the same, namely the order in which I added the categories, thus by ID. I have three levels of categories and I only want to show the first level of parents in alphabetical order. How hard can it be? :(

  5. Jack
    Posted 5 years ago #

    I reduced the code to this

    <?php wp_list_categories('show_count=0&title_li=&depth=1&exclude=1');

    and it still doesn't order the categories by name...

  6. Jack
    Posted 5 years ago #

    Found the cause...
    I use the Import Category plugin and this breaks the ordering.
    I already contacted the author of this otherwise great plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic