I want to order my list by a field value.
But in query, I have use another meta key.`
Here is the code:
$args = array(
'post_type' => 'schedule-public',
'meta_key' => 'category_training',
'meta_value' => 'ISO',
'meta_key' => 'start_date',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
while ( $the_query->have_posts() ) : $the_query->the_post();
.......;
endwhile;
endif;
The result, there’s no post displayed.
What should I do?
Hi @fadhil_ks,
Thanks for the post.
In this use case, I would recommend you make use of a meta_query to filter the posts by the custom field value.
This is explained in detail here: https://codex.wordpress.org/Class_Reference/WP_Query
I hope this helps.