Custom Fields
Re-Envisioned
Support General JSON Data getting reformated on Save/Edit

This topic contains 4 replies, has 2 voices, and was last updated by  Anh Tran 1 year, 5 months ago.

  • Creator
    Topic
  • #8632

    joeporterme
    Participant

    I have a field that is for display purposes only… i have posts getting imported into wordpress automatically and applying meta values like this on import:

    add_post_meta($wpid, ‘gnl_galleries_album_images’, $image_list);

    $image_list being a php array.

    On import its being stored in the database like this:

    a:60:{s:7:”G9K4ZnD”;a:2:{s:5:”thumb”;s:185: ………

    Now I have a Metabox.io Text box that is read only on the post that just displays that JSON data for reference.

    If i edit the post and hit save, the record in the meta table changes to something like this:

    {“G9K4ZnD”:{“thumb”:”https:/…… etc.

    How do i have the Metabox.io maintain the original format and not change the JSON structure?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #8633

    joeporterme
    Participant

    testing, if i remove the field from “display” the field maintains it structure in the database.. which i guess i can just remove it from showing.. but its nice to see for a reference on importing script.

    I guess, is it possible to have a field show that is display only and not updated on save. or if it does run the update on the field, keep the same format.

    #8646

    Anh Tran
    Keymaster

    Hello,

    Now I have a Metabox.io Text box that is read only on the post that just displays that JSON data for reference.

    Where does the JSON data come from? I see you store an array in the post meta, which is a serialized array.

    #8650

    joeporterme
    Participant

    its just data from an old system that is actually just a php array that gets assigned to the post using add_post_meta … because i dont think you have your own version of add_post_meta correct?

    Then im just using metabox.io to display only

    #8660

    Anh Tran
    Keymaster

    But when you imported, you already used add_post_meta() which converts the array into serialized string. So it’s not JSON anymore. I’m quite confused about that.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.