Support » Plugins » Hacks » include/require a file from another directory

  • Resolved jonathandsimmons


    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:

    setting root path:

    Hardcoding path:

    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • try something like:

    <?php include(home_url().'/path/to/your/file.txt'); ?>

    Is the file completely outside of your wordpress installation directory? If so, it might work better for you to create a symlink to it within the wordpress directory and include/require that.

    ln -s /path/to/file/myfile.php /word/press/location/plugins/myfile/myfile.php

    I fixed it. I should know by now not to code past midnight.

    To be honest it must have just been a type somewhere because this morning I opened the file and typed the following and it worked fine.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘include/require a file from another directory’ is closed to new replies.