Created
February 28, 2016 21:44
-
-
Save timmcdaniels/b34a828adbf079566210 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| *Get distinct values of custom field from post type | |
| * | |
| *@return void | |
| *@since 0.1 | |
| */ | |
| function get_distinct_from_post_type ( $field, $post_type ) { | |
| global $wpdb; | |
| $sql = "SELECT DISTINCT meta_value FROM $wpdb->postmeta pm, $wpdb->posts p WHERE meta_key = '$field' AND pm.post_id=p.ID AND p.post_type='$post_type' ORDER BY meta_value"; | |
| return $wpdb->get_results( $sql, ARRAY_A ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment