Skip to content

Instantly share code, notes, and snippets.

@harisrozak
Created June 13, 2017 11:20
Show Gist options
  • Select an option

  • Save harisrozak/702b16f736aa68ab9d8c032cf0a79160 to your computer and use it in GitHub Desktop.

Select an option

Save harisrozak/702b16f736aa68ab9d8c032cf0a79160 to your computer and use it in GitHub Desktop.
WordPress :: Sample WPDB
<?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