I like doing experiments with Wordpress and scraping and I wanted to have a cron call a file outside of the normal Wordpress file structure. But this file needed to still be able to easily add posts and anything else WP offers.

This meant that I need to inclue Wordpress in this PHP file. It's actually quite simple:

require_once(rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/wp-load.php');

This will load Wordpress and all of it's features into any custom php file you want.

This can also help you if you're getting error messages saying that Wordpress functions don't exist.