How to use php includes inside of a wordpress post?

Apr 1st, 2011 | By | Category: Internet

Unfortunately traditional Server side includes don’t work for loading external pages on remote domains/servers, or at least not that i’ve been able to find so far.  After a bit of research I’ve found two separate solutions to this:

1.)

The first solution is the more secure solution and is specifically for scenarios where you, the admin, or registered users of your blog only will be able to access the php includes.  You need to install the wordpress plugin: php-execution and then put the following code into your post:

<?
$a = file_get_contents(“http://www.somedomain.com/file.php”);
echo ($a);
?>

2.)

This next example is far less secure as php execution will be available to everyone hitting your website.  You will need to install the Exec-PHP plugin for this and insert the following code into your post:

<?php $a = file_get_contents(‘http://www.somedomain.com/file.php’); echo ($a); ?>

 

Hope that helps!

Tags: , , , ,

Leave a Comment