0

Good afternoon everyone.

I have a website made with wordpress version 5.02. I want to use Rest Api functionality for developing native android application. At this address https://my-site/wp-json I receive a response with all endpoints available in Worpress Rest API.

I am interesting in getting post content by this url. https://my-site/wp-json/wp/v2/posts/4982 By this url I receive post info. By key "content", "rendered" I can get the post page in html format.

{
  "id": 4982,
  "date": "2018-03-18T17:26:46",
  "date_gmt": "2018-03-18T14:26:46",
  "modified": "2018-03-18T17:26:46",
  "modified_gmt": "2018-03-18T14:26:46",
  "slug": "relefnoe-telo",
  "status": "publish",
  "type": "post",
  "content": {
    "rendered": " html page here",
    "protected": false
  }}

I want to put the post info to my appication natively. Could you tell me please can I get post content in json format like this:

{
  content: {
    "title": "article title",
    "image": "https://image.url",
    "gallery": [
      {
        "url": "https://image.url"
      },
      {
        "url": "https://image.url"
      }
    ],
    "descr": "description"
  }
}
  • Is the data from a WordPress install that you have control over? – birgire Dec 26 '18 at 9:11
  • @birgire. Thanks for response. I have control over the data. Could you help me? – Hryb Mikita Dec 26 '18 at 9:33
  • Have you looked into register_rest_route for your custom route ? This could also be a job for graphql? – birgire Dec 26 '18 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.