saving custom fields values as an array
-
I have been using Meta Box Plugin version 4.8.7, I really like this tiny plugin compared to ACF.
I need help to achieve something very complex scenario. I created one meta box and populated it with some fields using loop, there are 5 fields into each section. One field is URL, another is hidden field & the rest three are text fields and I want to save these three text fields with hidden field values as an array.
In my code
name
attribute of text fields looks likehidden field => name="arr[61][0]" field 1 => name="arr[61][1]" field 2 => name="arr[61][2]" field 3 => name="arr[61][3]"
Here 61 is the ID of some post.
There will be some more identical hidden fields with different
name
attributes and values. All these data will become one large array. I have pasting one single section result to explain it more.a:15:{i:61;a:4:{i:0;a:4:{s:5:"value";i:0;s:5:"start";i:0;s:7:"enabled";i:1;s:3:"end";i:15;}i:1;a:4:{s:5:"value";i:10;s:5:"start";i:15;s:3:"end";i:45;s:7:"enabled";i:1;}i:2;a:4:{s:5:"value";i:25;s:5:"start";i:45;s:3:"end";i:95;s:7:"enabled";i:1;}i:3;a:4:{s:5:"value";i:25;s:5:"start";i:95;s:3:"end";i:100;s:7:"enabled";i:1;}} ... ... ... }
As you can see there are 15 arrays and that post id as first key which contains another 4 arrays. Other than
value
,start, end, enabled
will be hidden.Other than saving all the data like above, I want to populate the all visible fields and hidden fields with the data which will be saved into array. That large array will be saved into single row of
wp_postmeta
table.Is this possible to achieve?
Let me know if I am failed to explain or if you have any question or doubt.
- The topic ‘saving custom fields values as an array’ is closed to new replies.