Rest API Get meta_box fields show all field type as TEXT

Support MB REST API Rest API Get meta_box fields show all field type as TEXT

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34188
    komozuro@gmail.com[email protected]
    Participant

    Hello,
    I created many number fields in metabox, also create ist metabox custom table fields
    But when I sent GET request via API calls, It always shown those fields as TEXT with double ""
    I need to get the INT type (whithout "") in response.
    Could I solve that?

    #34201
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you use the WordPress function get_post_meta(), it will return a string for all values retrieved from the database. So the number field also is a string when printing in Rest.

    After getting the value from Rest API, you can use JS or PHP function to change the data type (string to number).

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.