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.
Try using the ABSPATH constant as part of the name to include:
include(ABSPATH . 'wp-content/data.php');
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.
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!