• Resolved smietan

    (@smietan)


    I am attempting to include an external php file in my post. Here is the PHP code I have in my post:

    <?php
    include(‘/wp-content/data.php’);
    echo “fail”;
    ?>

    I am running WP 3.0.1, and I have the Exec-PHP 4.1 plugin successfully installed. Yes, the link to data.php is valid. The PHP code appears to be working because the post always renders “fail”. However, the include never shows up. The contents of the include file is html text, nothing fancy, just an unordered list, no other syntax, just raw html.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try using the ABSPATH constant as part of the name to include:

    include(ABSPATH . 'wp-content/data.php');

    Thread Starter smietan

    (@smietan)

    Thanks for the suggestion.

    Oddly, replacing:
    <?php
    include(‘/wp-content/data.php’);
    echo “fail”;
    ?>

    With:
    <?php
    include(ABSPATH . ‘wp-content/data.php’);
    echo “fail”;
    ?>

    Did not change the outcome. The text “fail” is still rendered on the page.

    Thread Starter smietan

    (@smietan)

    Actually, I had a typo. Your solution worked! This includes the contents of data.php successfully:

    <?php
    include(ABSPATH . ‘wp-content/data.php’);
    echo “fail”;
    ?>

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Include an external PHP file in my post?’ is closed to new replies.