Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#18346 closed defect (bug) (invalid)

orderby="title" does not work properly in WP_Query

Reported by: jobjorn's profile jobjorn Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Query Keywords:
Focuses: Cc:

Description

I am running a homemade plugin that displays an alphabetical post index. It didn't take me long to notice that "Äppelpaj med knäcktäcke" was sorted immediately after "Ajvarpasta med solrosfrön", that is, Ä after A rather than at the end of the alphabet - the swedish alphabet is like the english one but with three extra letters, Å Ä Ö, at the end. Since I did not really expect WordPress to handle the quirks of all languages, I ignored this.

However. It soon turned out that "Asiatisk gryta med tofu och plommon" was sorted after "Äppelpaj med knäcktäcke", meaning that the sort goes AÄA. Ä is treated as an A by WordPress.

In the get_posts loop, I'm adding a new header for each letter, based on when the first letter of the post changes from the first letter of the previous post. But since WordPress seems to treat Ä as A, and PHP rightly does not, I end up with two "A" headers with an "Ä" header in the middle.

This can't be right, can it?

I'm attaching my little (not entirely finished) plugin.

Attachments (1)

post-index-shortcode.php (1.5 KB) - added by jobjorn 13 years ago.
My plugin, in which the problem described in the ticket manifests clearly.

Download all attachments as: .zip

Change History (4)

@jobjorn
13 years ago

My plugin, in which the problem described in the ticket manifests clearly.

#2 @jobjorn
13 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Sorry about that - of course WordPress uses whichever sort order MySQL uses. If you are having a similar problem, you'll just have to change your character collation - I changed from utf8_general_ci to utf8_swedish_ci on the column "post_title" in wp_posts and now it works as it should do (even putting ä in the end).

#3 @SergeyBiryukov
13 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.