Access WordPress functionality outside of the WordPress directory

You might have an application, custom code or a cron job that is not a part of the WordPress file system but you need to use some of the WordPress functionalities, like accessing the database or functions. It is actually very simple to do. In your script you just need to include the wp-load file and call $wpdb. If you file or application is out side of the root WordPress directory be sure to reflect that in the include path.

include("<WP PATH>/wp-load.php");
global $wpdb;