WordPress.org

Forums

Wrong alphabetic sorting with wp_tagcloud() (7 posts)

  1. alainS
    Member
    Posted 7 years ago #

    Hi!

    I'm having a weird problem with using WP own tagcloud. It seems that alphabetic sorting is not suported for languages that are using non-English characters.
    For example: Our language is using a "č" (c with scaron) which is positioned beetwen "c" & "d" in alphabet. But wp_tag_cloud() function bring tags with "č" at the start, before "a" words. Same goes for "š"(s with scaron) and "ž" (z with scaron).

    the_tags() instead works perfectly. It sorts the tags in right alphabetic order.

    It seems that wp_tag_cloud() is not considering "international" characters as the_tags().

    Is there anyone that solved this?

  2. alainS
    Member
    Posted 7 years ago #

    just a bump

  3. WordPress uses the strnatcasecmp function for ordering tag by name, so this is purely a PHP problem, really.

    You might try adding a setlocale() statement to the wp-config.php file, to set your locale to the correct language. That will make PHP do the character comparisons correctly (if it can). However, I have no way to know what else that will affect in WordPress. It may have some other side effects as well. Be prepared for anything.

  4. alainS
    Member
    Posted 7 years ago #

    Thanks Otto42 for poining out a possible solution.
    But it's still interesting that the_tags() is working properly. Maybe if I try to find what is done there and then aply it to wp_tag_cloud()? But I'm not into PHP really ...so I'll try to find out and maybe actually solve it.
    Of course if some PHP freak knows how to solve this...don't be afraid :)

  5. alainS
    Member
    Posted 7 years ago #

    So far...so bad :(
    It seems that possible solutions found on the web and yours Otto42 were not able to solve this problem.

    I'm really pissed off as this means a "semi-functional" tag cloud.

    I still don't get it why "strnatcasecmp" is used for wp_tag_cloud() and not for the_tags() which is working perfectly with non-english characters.

    But as usual I'm waiting for one WP code freak out there to see my SOS ;)

  6. the_tags() is just retrieving a list of tags for the post. It uses the sorting in mySQL.

    The tag cloud, on the other hand, has more work to do, so it has to do the sorting itself in PHP.

    This could be fixed with some effort, but not with minor effort.

  7. kkretsch
    Member
    Posted 7 years ago #

    Now it is version 2.5 time and still the tag cloud isn't sorting well. Thats really bad.
    And I don't think one should point the finger to the ignorant php function. It just has to be corrected by using some other function.
    Is there demand from other europeans to solve this? I really would try if it will be included in some later release.

Topic Closed

This topic has been closed to new replies.

About this Topic