Function Reference: geodir_get_posts_default_sort

Summary

Returns default sorting order of a post type.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None

Package

GeoDirectory

Parameters

$post_type
(string) (required) The post type.

Default: None

Return Values

(bool|null|string)
  • Returns default sort results, when the post type is valid.
  • Otherwise returns false.

Change Log

Since: 1.0.0

Source File

geodir_get_posts_default_sort() is located in geodirectory-functions/custom_functions.php [Line: 534]

Source Code

function geodir_get_posts_default_sort( $post_type ) {

	global $wpdb;

	if ( $post_type != '' ) {

		$all_postypes = geodir_get_posttypes();

		if ( ! in_array( $post_type, $all_postypes ) ) {
			return false;
		}

		$sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array(
			$post_type,
			1,
			1
		) ) );

		if ( ! empty( $sort_field_info ) ) {
			return $sort_field_info;
		}

	}

}