How To Call WP_Query From A Subdomain?

Question

I have a PHP script running in WordPress, that uses a WP_Query to get the posts from one of my subdomains and return it as a JSON string. The script only receives the post data if I call it using the correct subdomain.

For example, if I go to news.example.com/api/news.php, the JSON prints correctly, but if I go to www.example.com/api/news.php it only prints an empty array.

How can I call a single script that will get data from a subdomain, even if I call it using the main domain? Or even better, if I call it from any subdomain?

0
, Bryan 8 years 2016-03-29T13:33:08-05:00 0 Answers 92 views 0

Leave an answer

Browse
Browse