Forum Replies Created
-
AuthorPosts
-
rubenhakMemberI could not see difference in response in the beta version. Could you explain what was changed?
get_post_meta returns unserialized id the key(the second argument) is empty, but if the key is set, the data returned is unserialized.
rubenhakMemberI figured out that I can use “unserialize” to get nested arrays. But i still have a question. Data of the group is grouped by fields:
{ "fieldA": [ "group_1_fieldA_value", "group_2_fieldA_value", "group_3_fieldA_value", "group_4_fieldA_value" ], "fieldB": [ "group_1_fieldB_value", "group_2_fieldB_value", "group_3_fieldB_value", "group_4_fieldB_value" ], "fieldC": [ "group_1_fieldC_value", "group_2_fieldC_value", "group_3_fieldC_value", "group_4_fieldC_value" ], }It would be nice to have the date grouped by instances. Something like this:
{ "group1": { "fieldA" : "group_1_fieldA_value", "fieldB" : "group_1_fieldB_value", "fieldC" : "group_1_fieldD_value", "fieldD" : "group_1_fieldC_value", }, "group2": { "fieldA" : "group_2_fieldA_value", "fieldB" : "group_2_fieldB_value", "fieldC" : "group_2_fieldD_value", "fieldD" : "group_2_fieldC_value", }, "group3": { "fieldA" : "group_3_fieldA_value", "fieldB" : "group_3_fieldB_value", "fieldC" : "group_3_fieldD_value", "fieldD" : "group_3_fieldC_value", }, }I know this is a less of a deal if there is just one level of grouping, but when there are several nested groups that becomes much more complex to consume the data using APIs. By any chance do you guys have methods to do the transformation?
Thanks,
Ruben
rubenhakMemberhi Steve, This is me again 🙂
I could retrieve the values of meta fields. For trivial fields the data is self descriptive. Though there are some complications when it comes to groups. I have group 2 level grouping and parsing the contents does not seem trivial at all. Please see following example:
a: 4: { s: 8: "fieldA";a: 1: { i: 0;s: 12: "valueA"; } s: 14: "fieldB";a: 1: { i: 0;a: 1: { i: 0;s: 10: "valueB"; } } s: 10: "fieldC";a: 1: { i: 0;s: 3: "valueC"; } s: 10: "innerGroup";a: 1: { i: 0;a: 3: { s: 6: "fieldD";a: 2: { i: 0;s: 3: "valueD1";i: 1;s: 3: "valueD2"; } s: 20: "fieldE";a: 2: { i: 0;s: 3: "valueE1";i: 1;s: 7: "valueE2"; } s: 24: "fieldF";a: 1: { i: 0;a: 1: { i: 0;s: 5: "valueF"; } } } } }It does not seem obvious how to parse this data structure. Are there any helpers available that would return the data in a more consumable form?
Thanks,
Ruben
rubenhakMemberCool, you guys are great! I’ll look through this and might get back with few more questions.
rubenhakMemberHi Steve,
Thanks for the response. I have managed to make this work. I have few followup questions.
1) I’ve managed to create a custom page and fields in a metabox. Can see and modify the values from editor admin screen. But when I open the custom page using permalink it shows up empty. How can I render some content based on the metabox field values?
2) How to get access to those metabox field values from REST APIs? I’m using WP REST API v2 to access the custom page: http://example.com/wp-json/wp/v2/movie/1234. But it does not include metabox data.
3) How are the metafield values stored? Could you share some internals.
Thank you,
Ruben -
AuthorPosts