Calling wp-load from a subdomain of a site not using wordpress


I am building a mobile specific site that does lots of things. One of these things is get data from the primary wordpress website. I had assumed I could just call wp-load.php from the subdomain and it will give me access to the wordpress framework, but this isnt the case.

If i just use require "/var/www/website/wp-load.php"; it redirects me from to

I looked around and found that you can define some wordpress arguments to prevent the redirect happening.

define( 'DOMAIN_CURRENT_SITE', '' );
require "/var/www/website/wp-load.php";

The problem now is I get an error message when I try to load the php script from the subdomain site.

“Error establishing a database connection”

I know I could just call the database directly and get the data but it would save me lots of trouble if i can reuse the WP framework to get images, tags etc.

, , Dan Hastings 4 years 2019-11-03T03:05:36-05:00 0 Answers 102 views 0

Leave an answer