How to include WordPress functions in custom .php file?

Solution:1

You’re on the right track. Try this instead:

require_once(“../../../../wp-load.php”);

Solution:2

To use wp functions in custom .php files, you must include wp-load.php in your file. You can do so by adding the following line:

require_once(PATH_TO.'/wp-load.php');

If WordPress is in the document root add instead:

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