PHP Code for posts
[resolved] Help getting correct path for a PHP include (2 posts)

  1. krisheinze
    Posted 2 years ago #

    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. http://tongaradio.com/wireready/wire/ads.htm.

    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.


  2. krisheinze
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • PHP Code for posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.