• Hi,

    i want to associate a featured image with a new post.

    At first, i successfully post the image using “/media” route and system return the correct answer (id, etc), then i try to construct the json object with title, content_raw an the featured_image field with de ID of previous return, but not work. The picture is created in the wordpress gallery, but is not associate with the post, because a see an empty “featured_image” field in the return data of the new post upload. What am I doing wrong?

    Regards,
    Heriberto

    https://wordpress.org/plugins/json-rest-api/

Viewing 1 replies (of 1 total)
  • Thread Starter Yoheri

    (@yoheri)

    Hi everyody,

    i answer myself becouse i found the solution !!!.

    The plugin have a filter “json_insert_post” that fire “attach_thumbnail”, but that function only associate the “featured_image” field if the post ID exist in the data base, so you can not use it when insert the post for first time.

    To do, you have to add you own filter “json_insert_post” and execute in the called function the system function set_post_thumbnail, with $post[ID] and $data[featured_image]. Becouse this filter is called after the JSON_plugin … the post exist and the are not problem.

    Meybe this can help to someone.

    Regards,
    Heriberto.

Viewing 1 replies (of 1 total)

The topic ‘featured Image on new post’ is closed to new replies.