0

I have the following args array

{  
   "ordreby":"meta_value_num",
   "meta_key":"_price",
   "posts_per_page":10,
   "offset":0,
   "post_type":"product",
   "post_status":"publish",
   "order":"asc",
   "suppress_filters":false,

}

when i do

  $myposts = get_posts($args);

the order by _price (or other meta keys) is not working.

any idea?

1

meta_query should be an array of arrays like:

...
'meta_query' => [
    [
        'key' => '...',
        'value' => '...',
    ],
],
...
  • is an array of arrays. The problem is in order by _price – Miguel Ruiz Bas Aug 30 '17 at 15:33
0

Change

"ordreby":"meta_value_num"

for

"orderby":"meta_value_num"

a dyslexic error xD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.