Skip to content

Instantly share code, notes, and snippets.

@byteface
Created March 31, 2017 01:27
Show Gist options
  • Save byteface/27b05db71559d8caa3ef679db95b5e4b to your computer and use it in GitHub Desktop.
Save byteface/27b05db71559d8caa3ef679db95b5e4b to your computer and use it in GitHub Desktop.
get wordpress database as json
require_once('../../../../wp-load.php');
private function get_store_data(){
$mydb = new wpdb('DB_USER','DB_PASSWORD','DB_NAME','DB_HOST');
$rows = $mydb->get_results("select * from some_wp_table");
$data=wp_json_encode( $rows );
return json_decode( $data, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment