0
votes

I am trying to grab data by using JSON in ionWordpress (ionic framework plugin) for wordpress.

I'm using the JSON API. Here's the data from my JSON.

    {
  "status": "ok",
  "count": 6,
  "count_total": 45,
  "pages": 8,
  "posts": [
    {
      "id": 1874,
      "type": "event",
      "slug": "stesets",
      "url": "http://www.web.com/page",
      "status": "publish",
      "title": "setst",
      "title_plain": "tests",
      "content": "testsetstst",
      "excerpt": "testsetststtes",
      "date": "2017-11-27 17:20:17",
      "modified": "2017-11-27 17:20:17",
      "categories": [],
      "tags": [],
      "author": {
        "id": 1,
        "slug": "test",
        "name": "test",
        "first_name": "",
        "last_name": "",
        "nickname": "test",
        "url": "",
        "description": ""
      },
      "comments": [],
      "attachments": [],
      "comment_count": 0,
      "comment_status": "closed",
      "thumbnail": "http://www.website.com/wp-content/uploads/2017/11/image.jpg",

My problem is when I tried to grab the data, it includes the [] as well. For eg.

{{post.thumbnail}}

This would show ["http://www.website.com/wp-content/uploads/2017/11/image.jpg"]

but I just want the link itself without the [" "]

How do I do this?

1
already try json_decode? - dianeryanto
Where are you using {{post.thumbnail}} , will you please post that code also? - Vivek Doshi
why dont you try {{post.thumbnail[0]}} - Diluk Angelo
I realized that it also happened to custom_fields as well. Is it because that I need to do the query for those. If so, how would I do it? Do I need to update the JSON API plugin inside wordpress? Basic elements like {{ post.title }} , {{ post.slug }} works fine. - Shukri Damit

1 Answers

0
votes

I used:

{{post.thumbnail[0]}}

as mentioned in comments by Diluk Angelo.