Skip to content

Instantly share code, notes, and snippets.

@onliniak
Created November 10, 2019 13:57
Show Gist options
  • Save onliniak/103fde78185b359ae1fa5b5ec8acb974 to your computer and use it in GitHub Desktop.
Save onliniak/103fde78185b359ae1fa5b5ec8acb974 to your computer and use it in GitHub Desktop.
Connect any php file to WordPress functions/database
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php';
global $wpdb;
$wpdb->get_var('Single row');
$result = $wpdb->get_results('Multiple rows');
foreach ( $result as $row )
{
var_dump($row);
echo $row->key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment