Today I was working on a project where I needed to use WordPress functionality outside of WordPress. After searching the web, Thanks to this Stackoverflow question I found out that I needed to include the wp-load.php file to get this done.
To get the wp-load file, you need the path to it. So here came the next problem; how to find the path on a nice way instead of doing this:
require_once( '../../../../wp-load.php' );
Thanks to Frankie Jarret’s article “The simplest way to require/include wp-load.php” I was able to find the path on a clean coded way.
$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] ); require_once( $parse_uri . 'wp-load.php');