WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. krisheinze
    Member
    Posted 11 months 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.

    http://wordpress.org/extend/plugins/php-code-for-posts/

  2. krisheinze
    Member
    Posted 11 months 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:

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

    The plugin works great. Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.