Query string order by custom field
I have code for custom post type, for custom taxonomy for displaying category posts. I am using Advanced Custom Fields
What I want is to order posts by custom field value, and I was wondering how I can do it?
For example if posts have custom field called “rating” how can I order posts from lowest value to highest?
Here's an example code
?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'brendovi' ) ); ?
?php if (have_posts()): query_posts($query_string.'posts_per_page=-1orderby=dateorder=ASC'); ?
?php while( have_posts() ) : the_post(); ?
This is the code that works just fine for displaying most recent custom post type posts, and they have custom fields called field_1, field_2, field_3. And users will fill those fields with numeric value. And later on on single post, I'll do the calculation summing those values and dividing by 3 to get avg value. Let's call it field_4.
I am stuck at displaying posts and sorting them by that field_4 with query string.
Perhaps I don't need query string?
Topic advanced-custom-fields query-string wp-query Wordpress
Category Web