I have a query in wordpress that looks like this,
$args = array(
'post_type' => 'our-team',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => array(
'date_published' => 'ASC',
)
);
I am wanting to order my results by 2 attributes, firstly by date_published and then secondly my a meta value "weight". Weight is a numeric value (1 or 2).
When I change it the query to be,
$args = array(
'post_type' => 'our-team',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'weight',
'orderby' => array(
'date_published' => 'ASC',
'meta_value' => 'ASC'
)
);
When I run this query it only returns posts that have a weight of 1?
2
Answers
Use
date
instead ofdate_published
i thinkdate_published
is not the right key. and weight should be in int so better to usemeta_value_num
instead ofmeta_value
try the below code.