php - orderby 'meta_value_num' is breaking my WP_QueryGet the solution ↓↓↓
I'm having an issue when trying to order my
WP_Query by a numeric ACF field. I've seen a few similar posts on here but none have been able to to help me resolve me issue.
Here are the args to my query:
$args = array ( 'post_type' => 'kb', 'post_status' => 'publish', 'meta_key' => 'order_in_list', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'tax_query' => array ( array ( 'taxonomy' => 'product', 'field' => 'term_id', 'terms' => $cat->term_id, ) ), );
order_in_list is the name of an ACF number field that exists on all posts of type 'kb'.
The above query currently returns nothing, however if I comment out the
meta_key line in the
args, it works fine. Does anyone have any idea what I'm doing wrong here?
People are also looking for solutions of the problem: object of class stdclass could not be converted to string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.