Wordpress custom post order -
i trying order each post in category custom field (using advanced custom fields plugin)
$the_query = new wp_query(array( 'posts_per_page' => -1, 'meta_key' => 'adult_price', 'orderby'=> 'meta_value_num', 'order' => 'asc' )); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); get_template_part( 'template-parts/content', get_post_format() ); endwhile; endif;
the problem it's somehow returning posts all other categories.
try code.
$args = array( 'orderby' => 'meta_value', 'meta_query' => array(array('key' => 'adult_price')), 'order' => 'asc', 'paged'=>$paged, );
Comments
Post a Comment