views:

43

answers:

3

is it correct or not because it show an error when im done that

if(is_page('payment-success')) { 
    include("/wp-content/ga-ecommerce-tracking/ga-ecommerce-tracking.php");
}
+1  A: 

include expects to take a path on the filesystem as its argument. You appear to be passing in root relative URL.

David Dorward
I disagree. I don't think that path is accessible as a WP URL. But it's probably a valid filesystem path.
Alin Purcaru
It starts with a `/`, if that is a valid filesystem path, then WordPress is installed in the system root directory! There **is** a web accessible directory called wp-content in the top level directory of a WordPress install, so if WordPress is installed in the webroot for a domain, then that **will** be an accessible URI if ga-ecommerce-tracking is put in it.
David Dorward
Well maybe that is his problem :). It should start with a `./`
Alin Purcaru
A: 

Try to give the full path. You can use dirname(__FILE__) to get the path of your including script and build from there with the relative path.

Also check what file_exists tells you about what you want to include.

Alin Purcaru
+1  A: 

Include accepts absolute path, relative path or a URL stream as its argument. But you are using a wrong absolute path here. Try making it to relative path ( I am assuming that you are editing a file in Wordpress root directory, if not change the path accordingly)

if(is_page('payment-success')) { 
    include("./wp-content/ga-ecommerce-tracking/ga-ecommerce-tracking.php");
}
Joyce Babu