Last active
August 29, 2015 14:01
-
-
Save bonsak/619464e15b01d1b2fdb6 to your computer and use it in GitHub Desktop.
wpdb - get title from posttype
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
| <?php | |
| /*-----------------------------------------------------------------------------------*/ | |
| /* wpdb get title from post type | |
| /*-----------------------------------------------------------------------------------*/ | |
| $post_type = "project"; | |
| $results = $wpdb->get_results( | |
| $wpdb->prepare( " | |
| SELECT post_title | |
| FROM $wpdb->posts | |
| WHERE post_type = %s | |
| ORDER BY post_title ASC", $post_type ) ); | |
| // Return result | |
| echo json_encode($results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment