Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

3 Answers 3

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.

include($_SERVER['DOCUMENT_ROOT']."/yourfile.php");

Cheers!!

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

 
discard

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.