// Force a short-init since we just need core WP, not the entire framework stack
define( 'SHORTINIT', true );
// Build the wp-load.php path from a plugin/theme
$wp_root_path = dirname( dirname( dirname( __FILE__ ) ) );
// Require the wp-load.php file (which loads wp-config.php and bootstraps WordPress)
require( $wp_root_path . '/wp-load.php' );
// Include the now instantiated global $wpdb Class for use
global $wpdb;
// Do your PHP code for rapid AJAX calls with WP!
// Example: Retrieve and display the number of users.
$user_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->users;" ) );
echo " User count is {$user_count} ";
|