Created
June 13, 2017 11:20
-
-
Save harisrozak/702b16f736aa68ab9d8c032cf0a79160 to your computer and use it in GitHub Desktop.
WordPress :: Sample WPDB
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 | |
| global $wpdb; | |
| $query = "SELECT $wpdb->posts.ID | |
| FROM $wpdb->posts | |
| WHERE $wpdb->posts.post_type = 'facility' | |
| ORDER BY RAND() | |
| LIMIT 8"; | |
| $results = $wpdb->get_col($wpdb->prepare( $query )); | |
| $ar_posts = array(); | |
| if($results) { | |
| foreach ( $results as $id ) { | |
| $post = get_post( intval( $id ) ); | |
| setup_postdata( $post ); | |
| $ar_posts[] = hb_2015_get_archive_lists(); | |
| } | |
| } | |
| // echo | |
| require_once(get_stylesheet_directory() . '/template-parts/archive-facility-posts.php'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment