Include WordPress environment in a plain PHP page

There comes a time for most serious WordPress developers when they are developing a WordPress site but need a separate PHP page which needs to access WordPress variables, functions and classes, but which for some reason cannot be part of the theme or a plugin.

Here’s the coding pattern for that:

require 'wp-load.php';
/* your totally unique and original code here */

Just make sure that the require statement has the correct relative path to wp-load.php (it’s in the root directory of a WordPress installation).

Because the entire WordPress environment is loaded, you have access to the database via the $wpdb class, and much more.


  1. Thank you for this informational article. . This article really helped me

    Thanks for sharing, keep writing 🙂

  2. Thanks for sharing this post. It’s very helpful for me.

  3. informative article..thank u for posting

Add a Comment

If you have used this form and would like a copy of the information held about you on this website, or would like the information deleted, please email