• Resolved WayneSmallman

    (@waynesmallman)


    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

    (@waynesmallman)

    Any takers? I could really do with some help here.

    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…

    From: 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?

    What he said… 😉

    Thread Starter WayneSmallman

    (@waynesmallman)

    @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.