My old workaround for using $wpdb no longer works in WordPress 3.4, but there is similar functionality built-in now. It loads a lot more than I was in my old method, but not as much as the full WordPress core being loaded.
WordPress 3.4+ Method
define( 'SHORTINIT', true );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
Nice, it’s just what I have been looking for. Works with 3.5 WP. Tnx 😉
Thank you so much. Super helpful.
Perfect. Moving my site to WordPress but have had a heck of a time using my external mySQL database that I need. This was the final piece.
your tut assumes my wp installation is in server root. what if i have wp installed in example.com/blog/ ?
Just edit the require line.
require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/blog/wp-load.php’ );
Cool! thanks, but;
few stupid questions:
What is ‘DOCUMENT_ROOT’? The php file? The site domain?
Do I still need to use $wpdb prefix?
Do I can use ordinary sql syntax or need wp api?
Thnks,
Still works great in 3.9.1. Thanks!