Displaying Content with WP Rest API

I will assume you want to use PHP to display this data directly using a template, there are alternatives such as using another language or actually creating posts via the API. Simply put you want to take the JSON string and convert it into a PHP object or array using json_decode. http://php.net/manual/en/function.json-decode.php. Once the JSON … Read more

Cannot access elements of json object

The result that is currently returned is raw text, which means data[0] accesses the first element (i.e. character) of the string, which is {. Obviously, you want to turn the returned data into a JSON object. To do this, jQuery.ajax() has a nifty property called dataType, which determines the way jQuery interprets the data returned … Read more

WordPress JSON API returns normal site page in html. How do I get it to give me JSON?

I’m likely doing it wrong, but when I form my requests for a WordPress installation at http://www.example.com/ like this: http://www.example.com/index.php?rest_route=/my/rest/route/here I end up getting proper responses back. I had a heck of a time figuring this out and ended up grokking a URL formatted like that in the HTML returned to me. I was expecting … Read more

How can I export post data in xml format?

I just want to make my own exporter Well, export_wp() will fetch the data (it builds the sql query, I think). So I’m not sure the benefit of using an api request to try and hand that data to export_wp(), unless you mean to generate the arguments for it via an endpoint, or some values … Read more