Tell me more ×
WordPress Answers 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 PHP`s include. Also please specify if you use WordPress itself in the root, and how you set up your system. – fischi Feb 20 at 9:03

3 Answers

You should use something like

require_once( dirname( dirname( dirname( dirname( __FILE__ )))) . '/wp-load.php' );
share|improve this answer
1  
Please explain what this code does and how it could help – bungeshea Feb 20 at 10:04

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

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

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.