Support » Plugin: PHP Code for posts » Help getting correct path for a PHP include

  • Resolved krisheinze


    I have a folder on my server at the same level as the wordpress folder in the directory tree with content that I want to include in my new WordPress site. I have tried several variations of pathing for my include using this plug-in with no luck. I tried an absolute URL in the include, I tried just a / for a root directory beginning and I tried a relative link with a bunch of ../../../../ syntax. As far as I can tell, the plugin is expected, but my pathing is just incorrect. I am familiar with using PHP includes just writing my own PHP pages, but this is one of my first go-rounds trying to figure out the WordPress system.

    I can bring up the htm file at the absolute URL so I know that is correct.

    This is the error I see on the website:
    Warning: include(../../../../wireready/wire/ads.htm) [function.include]: failed to open stream: No such file or directory in /home/tongara/public_html/wordpress/wp-content/plugins/php-code-for-posts/PHPPostCode.php(79) : eval()’d code on line 1

    Can anyone help please? Thanks.

Viewing 1 replies (of 1 total)
  • I was able to figure this out using tricks from other support forum questions. Instead of trying to figure out the correct path I used this code:

    $root = realpath($_SERVER["DOCUMENT_ROOT"]);
    include "$root/wireready/wire/ads.htm";

    The plugin works great. Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Help getting correct path for a PHP include’ is closed to new replies.