#28589 closed defect (bug) (invalid)
Warning on Usage of WP_Query() with Orderby Array
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.9.1 |
| Component: | Query | Keywords: | close |
| Focuses: | Cc: |
Description
When Using Orderby as array, like:
'orderby' => array(
array(
'meta_key' => 'ereignis-datum',
'field' => 'meta_value_num',
'order' => 'DESC'
)
)
your get
Warning: urldecode() expects parameter 1 to be string, array given in /subdomains/muenzenbergforum.de/htdocs/wp-includes/query.php on line 2634
Since several version i'm forced to make @urlencode to avoid having the warning on the page.
But with every update of course it comes back, since query.php is overwritten.
Change History (5)
#3
follow-up:
↓ 4
@
11 years ago
- Resolution invalid deleted
- Status changed from closed to reopened
The codex does indicate that it is possible to pass an array to 'orderby', though:
Mulitiple orderby/order pairs
'orderby' => array( 'meta_value_num' => 'DESC', 'title' => 'ASC' ), 'meta_key' => 'age'
In the description of "Order & Orderby Parameters" the codex also states the following:
order (string | array) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'. An array can be used for multiple order/orderby sets.
But when passing an array to 'order' I receive the following warning:
Warning: strtoupper() expects parameter 1 to be string, array given in
This is not a bug.
orderbydoesn't accept anything other than a string, so what you're trying to pass (an array) is actually not support byWP_Query. You should alter yourorderby-parameter (by usingorderby => 'meta_value_num', combined with the propermeta_keyquery parameter, for example).Closing as invalid.