Skip to content

Instantly share code, notes, and snippets.

@colegeissinger
Created March 12, 2013 19:37
Show Gist options
  • Save colegeissinger/5146253 to your computer and use it in GitHub Desktop.
Save colegeissinger/5146253 to your computer and use it in GitHub Desktop.
Use this to load the WP Bootstrap anywhere. Of course, if you aren't loading this into multiple scripts, just use the code inside the function and paste it directly into your PHP script.
function load_wp_bootstrap() {
// Traverse the directory back to the root of the WordPress install.
// Adding a dirname() will go back one directory (equivilent to ../).
$root = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
// Load the WordPress Bootstrap
if ( file_exists( $root . '/wp-load.php' ) ) require_once( $root . '/wp-load.php' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment