Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Last active June 26, 2017 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelz/5aef40926ee37836a679c27ee05f4bb5 to your computer and use it in GitHub Desktop.
Save mikaelz/5aef40926ee37836a679c27ee05f4bb5 to your computer and use it in GitHub Desktop.
<?php
$wpdb2 = new wpdb('USER', 'PASS', 'DB_NAME', 'HOST');
$sql = "SELECT *
FROM wp_posts
WHERE post_type = 'product'
AND post_status = 'publish'
";
$products = $wpdb2->get_results($sql, ARRAY_A);
foreach ($products as $product) {
// Do your magic
}
$wpdb2->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment