WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can't include files in other directories (6 posts)

  1. McGuirk
    Member
    Posted 7 years ago #

    I've been using includes in a couple of different files (such as index.php in one of my theme directories) and it has worked fine as long as the file I'm trying to include is in the same directory as the file WITH the include.

    In other words, I have this in my index.php file:

    if(date('j') == '1') {
    	include('1.php');
    }

    This works fine, assuming 1.php is in the same directory as index.php. What I need is to be able to do the same thing with 1.php residing in a subdirectory, such as:

    if(date('j') == '1') {
    include('/somedirectory/1.php');
    }

    But that never seems to work. It renders the whole page fine (since it's just an include) but nothing shows up where the stuff from 1.php should be.

    Anybody know the secret to this?

  2. McGuirk
    Member
    Posted 7 years ago #

    Nobody? :(

  3. Doodlebee
    Member
    Posted 7 years ago #

    I believe you need the full server path to the include. NOT the http:// path, and NOT a relative path, as you currently have. Just the full server path.

  4. McGuirk
    Member
    Posted 7 years ago #

    True, but that isn't working either.

    :\

  5. vkaryl
    Member
    Posted 7 years ago #

    That's weird. Full server path works fine for me all the time. You're not getting any errors? Have you checked with your host to see if they disallow server-path access for some reason?

  6. McGuirk
    Member
    Posted 7 years ago #

    Ok I figured it out with some help from my server admin. We had php running in safe mode which meant that in order for everything to work all the files had to have the same owner. Since somebody else owned all of the wordpress install files and I owned these new files there was a problem. Everything is fixed now that I have ownership of the whole enchilada. Thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Topic