How to include WordPress functions in custom .php file?
Well if someone has newer PHP versions installed (ver >= 5.5.x) then they can also try the below code in the root script in WordPress website directory itself:
<?phpdefine("WP_ROOT", __DIR__);define("DS", DIRECTORY_SEPARATOR);require_once WP_ROOT . DS . "wp-load.php";
Or
<?phpdefine("WP_ROOT", __DIR__);define("DS", DIRECTORY_SEPARATOR);require_once WP_ROOT . DS . "wp-blog-header.php";
I guess this is a more direct and clean approach and doesn't involve manually adding slashes and changing diretories by ..
.
Hope this helps someone.