- This topic has 3 replies, 2 voices, and was last updated 6 years, 9 months ago by
Steve.
-
AuthorPosts
-
-
May 7, 2015 at 10:13 am #3677
ndbeMemberMaybe someone will help me because documentation isn’t helping. So i got this code:
/* Title: realization Description: basic parameters Template: realizations Context: normal Priority: high Order: 1 Collapse: false Meta box: false */ piklist('field', array( 'type' => 'group' ,'label' => __('Tasks') ,'columns' => 12 ,'add_more' => true ,'scope' => 'post_meta' ,'field' => 'test_field' ,'serialize' => 'true' ,'fields' => array( array( 'type' => 'text' ,'field' => 'city' ,'columns' => 12 ), array( 'type' => 'text' ,'field' => 'name' ,'columns' => 12 ) ) ));And i have a couple of questions:
1.
when i save something and use get_post_meta to retrieve it and dump it to the screen with var_dump i get something like this:
"a:2:{s:4:"city";a:2:{i:0;s:5:"test1";i:1;s:5:"test3";}s:4:"name";a:2:{i:0;s:5:"test2";i:1;s:5:"test4";}}"
How to parse this into something more readable?2.
I can’t see this in standard custom fields metabox, why? -
May 7, 2015 at 3:34 pm #3679
SteveKeymaster@ndbe– Welcome to the Piklist community!
1) When you set the field (i.e.
'field' => 'test_field') in a group field, you are telling Piklist you want the other fields to be placed in an array of the main field. Yes… that sounds pretty tricky. The easiest thing to do is just remove'field' => 'test_field', and you should be able to get the other fields usingget_post_metaas individual fields.2) Your metabox doesn’t look standard because you turned that feature off. In the comment block you set
Meta box: false. Just remove that and all will be good.Let us know if you need any more help
-
May 8, 2015 at 2:18 am #3681
ndbeMember1. Never mind i got this 🙂
2. I meant WordPress “custom fields” meta box (not the look of my metabox). As You can see I have
'scope' => 'post_meta'
I can access this variable with get_post_meta but I can’t see this in “custom fields” metabox in admin panel. Normal fields (not group fields) after saving appear in “custom fields” metabox. Is that normal behavior or some bug or something? -
May 9, 2015 at 8:30 am #3684
SteveKeymasterI believe the custom fields metabox only shows text-type values. When you saved the field with your original configuration it was saving as an array. With the configuration I suggested you should see the data in the custom fields meta box.
-
-
AuthorPosts
- You must be logged in to reply to this topic.