Ionic Wordpress JSON API与WP Rest API 2

时间:2017-12-11 07:55:30

标签: json wordpress rest api ionic-framework

我试图解析image_gallery,它可以从WP REST API 2获得,但不能从JSON API获得。我使用iononic的ionWordpress模板从Wordpress获取数据,并且它已经编码用于使用JSON API获取数据。

这里是从JSON API解析的JSON数据

  "posts": [
    {
      "id": 383,
      "type": "event",
      "slug": "motorcross-challenge",
      "url": "http://www.brunei.events/brunei/event/motorcross-challenge/",
      "custom_fields": {
        "event_type": [
          "Regular event"
        ],
        "zooming_factor": [
          "17"
        ],
        "address": [
          "Motorcross Track, Tutong, Tutong District, Brunei"
        ],
        "geo_latitude": [
          "4.8243656000000135"
        ],
        "geo_longitude": [
          "114.66116149999993"
        ],
        "map_view": [
          "Road Map"
        ],
        "featured_type": [
          "none"
        ],
        "featured_h": [
          "n"
        ],
        "featured_c": [
          "n"
        ],
        "country_id": [
          "32"
        ],
      },
    }

这里是WP Rest Api 2的数据

{
    "featured_img": false,
    "image_gallery": [
      "http://www.brunei.events/wp-content/uploads/2017/12/WhatsAppImage20171117at4.34.19PM1512704778.jpeg"
    ],
    "html_var": {
      "package_id": "49",
      "package_name": "Free",
      "post_city_id": "4",
      "end_time": "21:30",
      "st_time": "19:30",
      "end_date": "2017-12-17",
      "st_date": "2017-12-15",
      "event_type": "Regular event",
      "map_view": "Road Map",
    }
  }

是的我注意到两者都不一样,它只是一个示例,表明使用WP Rest API,它获取了image_gallery而不是JSON API。是否有一种解决方法可以在JSON API中获取此功能。我是否必须修改JSON API中的代码?

提前致谢!

0 个答案:

没有答案