wordpress自定义rest api-在数组内过滤对象

时间:2018-12-04 10:54:13

标签: wordpress wordpress-rest-api

我有一个wordpress api rest 我可以使用

使用“翻译者” ID过滤结果

/ wp-json / wp / v2 / videos?filter [meta_key] = translators&filter [meta_value] = 6780

但我无法使用“ artist_video”对其进行过滤,因为它是一个数组 而且我不知道如何使用参数,这是json代码

{
   "id":6779,
   "date":"2018-12-03T07:19:33",
   "date_gmt":"2018-12-03T07:19:33",
   "guid":{
      "rendered":"http://test.com/?post_type=video&p=6779"
   },
   "modified":"2018-12-04T09:18:04",
   "modified_gmt":"2018-12-04T09:18:04",
   "slug":"lana-del-rey-video-games-%d9%85%d8%aa%d8%b1%d8%ac%d9%85-%d8%b9%d8%b1%d8%a8%d9%8a",
   "status":"publish",
   "type":"video",
   "link":"http://test.com/video/lana-del-rey-video-games-%d9%85%d8%aa%d8%b1%d8%ac%d9%85-%d8%b9%d8%b1%d8%a8%d9%8a/",
   "title":{
      "rendered":"Lana Del Rey – Video Games"
   },
   "content":{
      "rendered":"",
      "protected":false
   },
   "excerpt":{
      "rendered":"",
      "protected":false
   },
   "author":4,
   "featured_media":0,
   "menu_order":0,
   "comment_status":"open",
   "ping_status":"closed",
   "template":"",
   "tags":[
      37
   ],
   "video-category":[
      32
   ],
   "acf":{
      "video_id":"cE6wxDqdOV0",
      "app_title":"Video Games",
      "subtitle_upload":"test.srt",
      "translators":{
         "ID":6780,
         "post_author":"4",
         "post_date":"2018-12-03 07:16:59",
         "post_date_gmt":"2018-12-03 07:16:59",
         "post_content":"",
         "post_title":"sss",
         "post_excerpt":"",
         "post_status":"publish",
         "comment_status":"open",
         "ping_status":"closed",
         "post_password":"",
         "post_name":"%d9%85%d8%ad%d9%85%d8%af-%d8%b3%d9%84%d9%8a%d9%85%d8%a7%d9%86-sm7_e",
         "to_ping":"",
         "pinged":"",
         "post_modified":"2018-12-03 07:16:59",
         "post_modified_gmt":"2018-12-03 07:16:59",
         "post_content_filtered":"",
         "post_parent":0,
         "guid":"http://test.com/?post_type=translator&p=6780",
         "menu_order":0,
         "post_type":"translator",
         "post_mime_type":"",
         "comment_count":"0",
         "filter":"raw"
      },
      "editor":{
         "ID":6780,
         "post_author":"4",
         "post_date":"2018-12-03 07:16:59",
         "post_date_gmt":"2018-12-03 07:16:59",
         "post_content":"",
         "post_title":" sss",
         "post_excerpt":"",
         "post_status":"publish",
         "comment_status":"open",
         "ping_status":"closed",
         "post_password":"",
         "post_name":"%d9%85%d8%ad%d9%85%d8%af-%d8%b3%d9%84%d9%8a%d9%85%d8%a7%d9%86-sm7_e",
         "to_ping":"",
         "pinged":"",
         "post_modified":"2018-12-03 07:16:59",
         "post_modified_gmt":"2018-12-03 07:16:59",
         "post_content_filtered":"",
         "post_parent":0,
         "guid":"http://test.com/?post_type=translator&p=6780",
         "menu_order":0,
         "post_type":"translator",
         "post_mime_type":"",
         "comment_count":"0",
         "filter":"raw"
      },
      "release_date":"",
      "parts":false,
      "artist_album":false,
      "artist_video":[
         {
            "ID":2425,
            "post_author":"4",
            "post_date":"2017-09-14 15:40:19",
            "post_date_gmt":"2017-09-14 15:40:19",
            "post_content":"",
            "post_title":"Lana Del Rey ",
            "post_excerpt":"",
            "post_status":"publish",
            "comment_status":"open",
            "ping_status":"closed",
            "post_name":"lana-del-rey-",
            "post_modified":"2017-09-14 15:40:19",
            "post_modified_gmt":"2017-09-14 15:40:19",
            "post_content_filtered":"",
            "post_parent":0,
            "guid":"http://test.com/?post_type=artist&p=2425",
            "menu_order":0,
            "post_type":"artist",
            "post_mime_type":"",
            "comment_count":"0",
            "filter":"raw"
         }
      ],
      "feat_artist":[
   {
      "ID":823,
      "post_author":"4",
      "post_date":"2017-01-14 13:51:11",
      "post_date_gmt":"2017-01-14 13:51:11",
      "post_content":"",
      "post_title":"Eminem",
      "post_excerpt":"",
      "post_status":"publish",
      "comment_status":"open",
      "ping_status":"closed",
      "post_name":"eminem",
      "post_modified":"2017-01-14 13:51:11",
      "post_modified_gmt":"2017-01-14 13:51:11",
      "post_content_filtered":"",
      "post_parent":0,
      "guid":"http://test.com/?post_type=artist&p=823",
      "menu_order":0,
      "post_type":"artist",
      "post_mime_type":"",
      "comment_count":"0",
      "filter":"raw"
   }
]
   },
   "_links":{

   }
},

我使用这些插件

  • 高级自定义字段PRO

  • ACF到REST API

  • WP REST过滤器

0 个答案:

没有答案