WordPress.org

Ready to get started?Download WordPress

Forums

How to sort posts alphabetically by alphabet other than english? (2 posts)

  1. illis
    Member
    Posted 3 years ago #

    I've run into a very annoying problem:
    I'd need to list my posts in alphabetical order, that alphabet being scandinavian rather than US/english. In practice, this means some additional, accented characters (such as ä and ö) that go between the US ones.

    Does anyone have an idea on how to do this?
    I realize I can read the posts to an array and sort that, but there must be a better way (say, directly in wp-query) to go about this.

  2. illis
    Member
    Posted 3 years ago #

    My current solution: get the posts, store their IDs and sort keys (in this case the title) in an array, sort that array by sort key in PHP and use the IDs in this new order as a list for the WP query's post__in -parameter. Requires a simple filter hooked to 'posts_orderby' to make WP respect the post__in order.

    This works, but it's less than elegant solution given all the looping and stuff.

Topic Closed

This topic has been closed to new replies.

About this Topic