Title: Using &#8220;require&#8221; function in header.php
Last modified: August 19, 2016

---

# Using “require” function in header.php

 *  Resolved [WayneSmallman](https://wordpress.org/support/users/waynesmallman/)
 * (@waynesmallman)
 * [17 years ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/)
 * Hi guys!
 * I’ve developed a navigation system, which I want to use within WordPress. The
   system itself is a class file. I’m using the “_require_” function to pull in 
   the file and instantiating the class, then I’m calling the methods to build the
   navigation.
 * However, I can’t find the correct path for my folder “_library_” which is on 
   the root.
 * I’ve tried everything I know but I can’t get at the root from within the “_header.
   php_” file.
 * Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [WayneSmallman](https://wordpress.org/support/users/waynesmallman/)
 * (@waynesmallman)
 * [17 years ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080786)
 * Any takers? I could really do with some help here.
 *  [t31os](https://wordpress.org/support/users/t31os/)
 * (@t31os)
 * [17 years ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080789)
 * More details on the problem would be helpful.
 * I assume when you say require, you are referring to…
 * `require('myfile.php');` etc….
 * Could try $_SERVER[‘DOCUMENT_ROOT’] …
 * Print or Echo out your problem paths, and see what comes up…
 *  [Nommo](https://wordpress.org/support/users/nommo/)
 * (@nommo)
 * [17 years ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080817)
 * From: [http://uk3.php.net/function.require](http://uk3.php.net/function.require)
 * > If you use relativ paths in a php script (file A) that can be required by another
   > php script (file B), be aware that the relativ paths in file A will be relativ
   > to the directory, where file B is stored.
   >  You can use the following syntax
   > in file A, to be sure that the paths are relativ to the directory of file A:
   >     ```
   >     <?
   >     require(dirname(__FILE__)."/path/relative/file_to_include.php");
   >     ?>
   >     ```
   > 
 * and:
 * > if you want to include files with an absolut path reference, you can use:
   > `require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");`
   > this way you can organize your files in subdirectories trees.
 * Hope that helps?
 *  [t31os](https://wordpress.org/support/users/t31os/)
 * (@t31os)
 * [17 years ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080822)
 * What he said… 😉
 *  Thread Starter [WayneSmallman](https://wordpress.org/support/users/waynesmallman/)
 * (@waynesmallman)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080873)
 * [@t31os](https://wordpress.org/support/users/t31os/): “I’m using the ‘require’
   function” That’s self explanatory. There is only the one such function in PHP,
   as far as I am aware.
 * What I wrote is all of the detail there is to provide.
 * I’ve tried all of the standard global variables and none worked.
 * In the end, the only method that would / will work is: require (ABSPATH . ‘/library/
   classes/class.page.php’);

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using “require” function in header.php’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [require()](https://wordpress.org/support/topic-tag/require/)

 * 5 replies
 * 3 participants
 * Last reply from: [WayneSmallman](https://wordpress.org/support/users/waynesmallman/)
 * Last activity: [16 years, 12 months ago](https://wordpress.org/support/topic/using-require-function-in-headerphp/#post-1080873)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
