Viewing 3 reply threads
  • Author
    Posts
    • #3677
      ndbe
      Member

      Maybe 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?

    • #3679
      Steve
      Keymaster

      @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 using get_post_meta as 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

    • #3681
      ndbe
      Member

      1. 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?

    • #3684
      Steve
      Keymaster

      I 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.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.