[wp-trac] [WordPress Trac] #44219: null post json object reference when retrieve a media item

WordPress Trac noreply at wordpress.org
Thu May 24 21:57:59 UTC 2018


#44219: null post json object reference when retrieve a media item
-------------------------------+------------------------------
 Reporter:  nurcholisart       |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  REST API           |     Version:  4.8.2
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  rest-api
-------------------------------+------------------------------

Comment (by nurcholisart):

 Replying to [comment:1 birgire]:
 > Welcome to WordPress Trac @nurcholisart
 >
 > I think that means the featured image is not attached to any post, hence
 null.
 >
 > An image can only be attached to a single post.
 >
 > So I think this is expected, if your featured image is not attached to
 the post.
 >
 > Is that the case?

 Hi, @birgire thanks before...

 Actually, i have uploaded the image to that post in my wordpress
 dashboard. and the media is just for that post. here is my screen shot
 [[Image(http://oi64.tinypic.com/4r6fqt.jpg)]].

 But when i get it from wp rest api, the "post" object give me null return.
 i think it should return "post":7634. because, when i try to get other
 image detail from wp rest api, it's not give null return. example is like
 this:


 {{{
 {
         "id": 7839,
         "date": "2018-05-24T16:03:24",
         "date_gmt": "2018-05-24T09:03:24",

         ...

         "author": 93,
         "featured_media": 7846,

         ...
 }
 }}}

 the code above is response when i get https://himmahonline.id/wp-
 json/wp/v2/media/7846. and that image is the featured media in post id
 7839. here is the response when i retrieve post detail:


 {{{
 {
         "id": 7839,
         "date": "2018-05-24T16:03:24",
         "date_gmt": "2018-05-24T09:03:24",

         ....

         "author": 93,
         "featured_media": 7846,
         "comment_status": "open",

         ...
 }
 }}}
 https://himmahonline.id/wp-json/wp/v2/posts/7839

 The featured image object appears in json response.

 i need this to export my wordpress database to non-wordpress database.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44219#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list