Include WordPress environment in a plain PHP page

Published 06 Nov 2014 in Development, PHP & MySQL, WordPress by ZigPress

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. On 13 Nov 2014 at 05:18, Fikri Ferdiansyah said:

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

    Thanks for sharing, keep writing :)

  2. On 17 Nov 2014 at 16:55, Ruhul Amin said:

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

  3. On 24 Dec 2014 at 06:41, [email protected] said:

    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 [email protected].