wp_query order by title

If you’re trying to get them to order by ascending price, the problem is that ordering by title is a string comparison, not numeric. A solution would be to put the price in a custom field and orderby your custom field rather than title. You would add a meta_key param with the name of your meta key, and orderby meta_value_num. See WP_Query in Codex for more info.

Also- if you want all posts returned (which I assume is what you’re trying to do with setting it to such a high number), you can set posts_per_page to -1 instead and it will remove the LIMIT clause from the query.

Leave a Comment