WP_Query::parse_order
Parse an 'order' query variable and cast it to ASC or DESC as necessary.
Method of the class: WP_Query{}
No Hooks.
Returns
String. The sanitized 'order' query variable.
Usage
// protected - for code of main (parent) or child class $result = $this->parse_order( $order );
- $order(string) (required)
- The 'order' query variable.
Changelog
| Since 4.0.0 | Introduced. |
WP_Query::parse_order() WP Query::parse order code WP 6.9
protected function parse_order( $order ) {
if ( ! is_string( $order ) || empty( $order ) ) {
return 'DESC';
}
if ( 'ASC' === strtoupper( $order ) ) {
return 'ASC';
} else {
return 'DESC';
}
}