Function Reference: geodir_add_custom_sort_options
Summary
Add custom sort options to the existing fields.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
Package
GeoDirectory
Parameters
- $fields
- (array) (required) The sorting fields array.
- Default: None
- $post_type
- (string) (required) The post type.
- Default: None
Return Values
- (array)
- Returns the fields.
Change Log
Since: 1.0.0
Source File
geodir_add_custom_sort_options() is located in geodirectory-functions/custom_fields_functions.php [Line: 1848]
Source Code
function geodir_add_custom_sort_options($fields, $post_type) { global $wpdb; if ($post_type != '') { $all_postypes = geodir_get_posttypes(); if (in_array($post_type, $all_postypes)) { $custom_fields = $wpdb->get_results( $wpdb->prepare( "select post_type,data_type,field_type,site_title,admin_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc", array($post_type) ), 'ARRAY_A' ); if (!empty($custom_fields)) { foreach ($custom_fields as $val) { $fields[] = $val; } } } } return $fields; }