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 ![:)](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_sHNKmteN5cc2Z3yaKLdlGL12i-kyXSZ51C3j5CzCUXcYy1R0An2ZKfpcFXOlwZcajOwolerbQsQcJGsl7CLbzrtY1Eu5rm-8A6MzpQeMZh_IN9jDNeh5sqUmHejksP_o1u_thVjgTmiwoz4JXnMRN2g4m10HqBtlw=s0-d)
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/