You are here:  » Including onto a wordpress post

Support Forum



Including onto a wordpress post

Submitted by Harvey on Thu, 2008-09-04 15:08 in

Hi David,

I've been racking my non-php brains all morning to try and get this to work.

I'm using a wordpress plugin called Exec-php to attempt to include PT search results on a wordpress page.

So far I've managed to include phpinfo.php from the root using the following code:

<?php
 
require_once(ABSPATH'phpinfo.php'); 
?>

- as recommended here:

http://bluesome.net/post/2005/08/18/50/#globals

However, when I try to include a pricetapestry page:

<?php
 
require_once(ABSPATH'/pricetapestry/search.php'); 
?>

- I get the error at http://www.featuredbrands.co.uk/adidas-clothing/adidas-t-shirts/

Not expecting a bona-fide wordpress plugin or anything, but if you have any ideas/pointers of how best to include a search page (with keywords mindyou) that'd be great.

Submitted by support on Thu, 2008-09-04 15:28

Hi Harvey,

The error message indicates that it is down to the paths to the include files; which when you pull the script in outside of the Price Tapestry directory are wrong; because the script uses relative paths.

This can be fixed in includes/common.php as follows. In that file, you will find the following section:

  if (file_exists("config.php"))
  {
    require("config.php");
    $common_path = "includes/";
  }
  else
  {
    require("../config.php");
    $common_path = "../includes/";
  }

The best thing to do is to make the paths absolute, so instead of the above block, use:

  require("/home/users/you/httpdocs/pricetapestry/config.php");
  $common_path = "/home/users/you/httpdocs/pricetapestry/includes/";

Of course, you need to know what:

/home/users/you/httpdocs/pricetapestry/

...is on your server. One way to find out is to run this script in your Price Tapestry installation folder:

whereami.php:

<?php
  $path 
$_SERVER["SCRIPT_FILENAME"];
  
$path str_replace("whereami.php","",$path);
  print 
$path;
?>

...and whatever is displayed by that script, use as the absolute path in config.php!

Hope this helps!

Cheers,
David.

Submitted by Harvey on Fri, 2008-09-05 17:18

Thanks David, top stuff :)