If you want to use WordPress functionality in a PHP file that exists outside of your WordPress installation then you need to include
wp-load.php
. Perhaps you could call this “hooking into WordPress”.
Maybe you’re already using some sort of relative path method, like:
But this can create problems if directories change. You need a clean, dynamic way to get
wp-load.php
. So here is the simplest way to do it, with just two lines of code (place it at the very top of your file):
Short and sweet
Disclaimer: This is intended for experimental and development purposes only. It is not advised to redundantly load WordPress on live production environments. But, why?
http://frankiejarrett.com/the-simplest-way-to-require-include-wp-load-php/