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 subdomain.website.com to website.com.
I looked around and found that you can define some wordpress arguments to prevent the redirect happening.
define( 'DOMAIN_CURRENT_SITE', 'subdomain.website.com' );
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.
Leave an answer