WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to files from the root directory of my site inside my WordPress header file.

Is there any function for including a file from the root folder?

share|improve this question
There is no specific function other than PHPs include`. Also please specify if you use WordPress itself in the root, and how you set up your system. – fischi Feb 20 '13 at 9:03

If you are talking about the WordPress root, use:

include ABSPATH . "/extra-file.php";

ABSPATH is always the WordPress root, you can see that in your wp-config.php.

share|improve this answer

In your wp-config.php file, add the following line before /* That's all, stop editing! Happy blogging. */:

define( 'ROOT_FOLDER', dirname( __FILE__ ) );

Now you can use the following for including files from your root folder:

include ROOT_FOLDER . '/filename.php';
share|improve this answer

Its as simple as this.



share|improve this answer
$_SERVER['DOCUMENT_ROOT'] is not always the root of the WordPress installation. – toscho Oct 17 '13 at 8:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.