Order by title – but now built in wordpress func, sort the_title

I’m afraid it would be very hard to do. qTranslate stores all titles in one database field as concatenated string with some additional markup, so there is no chance to sort them using SQL and to do it fast.

You can do one of 2 things:

1. Stop using qTranslate

It really has many other flaws. You can use WPML or Polylang instead – both are much better.

2. Sort them in PHP

Don’t sort posts in query with SQL and sort them with PHP after running this query. WP_Query stores found posts in $wp_query->posts. You can sort this array with PHP. Of course you will have to select all posts to make it work, so if there are many posts in this query, it’s rather bad idea. But if there are only few of them, then it shouldn’t be so bad…

Sample code below – written in here, so may be buggy.

<?php
    $my_query = new WP_Query( array('post_type'=>'page', 'orderby'=>'title', 'order'=>'ASC', 'posts_per_page'=>-1) );
    if ( $my_query ->have_posts() ):
?>
<ul class="posts-list">
    <?php
        $found_posts = array();
        foreach ( $my_query->posts as $k=>$p ) {
            $found_posts[ apply_filters('the_title', $p->post_title) ] = $p;
        }
        ksort($found_posts);
        $i=0;
        foreach ($found_posts as $k=>$p) {
            $my_query->posts[$i++] = $p;
        }
    ?>
    <?php while ( $my_query->have_posts() ): $my_query->the_post(); ?>
        <li><h2><a href="https://wordpress.stackexchange.com/questions/123531/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></li>
    <?php endwhile; ?>
</ul>
<?php endif; wp_reset_postdata(); ?>