WordPress.org

Ready to get started?Download WordPress

Forums

include/require a file from another directory (2 posts)

  1. jonathandsimmons
    Member
    Posted 3 years ago #

    So I've tried everything I know to include/require a file from another directory within my wordpress install.

    Below is what I've tried can anyone tell me what I'm missing

    Move back through folder to the proper dir:
    include(../../../myfolder/myfile.php)

    setting root path:
    include($_SERVER['DOCUMENT_ROOT']."/services/charigfy.php")

    Hardcoding path:
    include(/home/mylogin/public_html/myfolder/myfile.php)

    These are just a few of the many. The folder is two folder back from my theme folder. Coming the other way its 1 folder deep past root.

    each time I get the error below:
    Warning: include(/home/mylogin/public_html/myfolder/myfile.php) [function.include]: failed to open stream: No such file or directory in /home/example/public_html/wp-content/themes/my_theme/home.php on line 13

    Its trying to add on the path to the end of home.php which of course won't work it doesn't exist. I'm aware normally you would ../../ however many directories you need to go back but that just isn't working.

    What am I missing?

  2. vankaa
    Member
    Posted 3 years ago #

    Am I wrong or you are missing quotation marks
    include('../../../myfolder/myfile.php'); ?

Topic Closed

This topic has been closed to new replies.

About this Topic