WP_Comment_Query::parse_order() WordPress Method

The WP_Comment_Query::parse_order() method is used to set the order of the comments to be returned. The default order is 'DESC', which will return the newest comments first.

WP_Comment_Query::parse_order( string $order ) #

Parse an ‘order’ query variable and cast it to ASC or DESC as necessary.


Parameters

$order

(string)(Required)The 'order' query variable.


Top ↑

Return

(string) The sanitized 'order' query variable.


Top ↑

Source

File: wp-includes/class-wp-comment-query.php

	protected function parse_order( $order ) {
		if ( ! is_string( $order ) || empty( $order ) ) {
			return 'DESC';
		}

		if ( 'ASC' === strtoupper( $order ) ) {
			return 'ASC';
		} else {
			return 'DESC';
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.