Including WordPress Functions in Custom .php Files
Having custom .php files that utilize WordPress functions can be beneficial. However, accessing these functions can lead to errors. In this case, a user attempted to include wp-blog-header.php using require_once but faced a 404 error.
To resolve this issue, it's advised to use wp-load.php instead. This file initializes WordPress and makes its functions available to your custom .php file. Here's the corrected code:
require_once("../../../../wp-load.php");
By making this modification, you should be able to successfully include WordPress functions in your custom .php file. Remember, wp-load.php needs to be loaded from the WordPress root directory, which is why the path in the require_once statement is "../../../../../wp-load.php".
The above is the detailed content of How to Successfully Include WordPress Functions in Custom .php Files?. For more information, please follow other related articles on the PHP Chinese website!