Viewing 5 reply threads
  • Author
    Posts
    • #7144
      titidodo
      Participant

      Hey everybody,
      i want to add three metaboxes to add content for a specific page.
      Here’s what i did:
      – installed piklist
      – added this folders to my theme: piklist/parts/meta-boxes
      – created three php files inside

      Here is an example of how the php files look like:

      <?php
      
      /*
        Title: Solution Panel Box 1
        Post Type: page
        id: 5
        collapse: true
        order: 10
       */
      
      piklist('field', array(
          'type' => 'text'
          , 'field' => 'home_solution1_title'
          , 'label' => 'Title'
          , 'columns' => 12
      ));
      piklist('field', array(
          'type' => 'file'
          , 'field' => 'home_solution1_icon'
          , 'label' => 'Icon'
          , 'options' => array(
              'modal_title' => __('Add File(s)', 'piklist-demo')
              , 'button' => __('Add', 'piklist-demo')
          )
      ));
      piklist('field', array(
          'type' => 'file'
          , 'field' => 'home_solution1_image'
          , 'label' => 'Image'
          , 'options' => array(
              'modal_title' => __('Add File(s)', 'piklist-demo')
              , 'button' => __('Add', 'piklist-demo')
          )
      ));
      piklist('field', array(
          'type' => 'group'
          , 'field' => 'home_solution1_checklist'
          , 'label' => 'Checklist'
          , 'columns' => 12
          , 'add_more' => true
          , 'fields' => array(
              array(
                  'type' => 'text'
                  , 'field' => 'home_solution1_checklist_title'
                  , 'label' => 'Title'
                  , 'columns' => 12
              )
              , array(
                  'type' => 'editor'
                  , 'field' => 'home_solution1_checklist_centent'
                  , 'label' => 'Content'
                  , 'columns' => 12
                  , 'options' => array(
                      'wpautop' => true
                      , 'media_buttons' => false
                      , 'teeny' => true
                      , 'dfw' => false
                      , 'textarea_rows' => 2
                  )
              )
              , array(
                  'type' => 'text'
                  , 'field' => 'home_solution1_checklist_morelink'
                  , 'label' => 'Link'
                  , 'columns' => 12
              )
          )
      ));

      The only changes i made in the other files is to change the ‘field’ key.

      -> All three metaboxes appear as desired when editing the page with the ID 5
      -> Problem: I inserted some data, saved and it worked out the first time. But all changes i make now won’t save.

      Thanks in advance for your help!!

    • #7149
      Steve
      Keymaster

      Do you see any errors with WP_DEBUG turned on? How about Chrome console?

    • #7151
      titidodo
      Participant

      Hey Steve! No errors with WP_DEBUG turned on and also no errors in Chrome console. 🙁
      If i fill the metaboxes with data and click the save button, it writes it to the database as shown in the attachment.
      “home_solution1_title” is filled with the value of the first save, values in the other fields won’t save.

      Attachments:
      You must be logged in to view attached files.
    • #7163
      Ico
      Member

      Hi,

      I have just the same problem, only on meta fields added to some, but not all custom page templates.

    • #7164
      titidodo
      Participant

      I added this code to my functions.php

      function post_type_support_init() {
          remove_post_type_support('post', 'custom-fields');
          remove_post_type_support('page', 'custom-fields');
      }
      add_action('init', 'post_type_support_init');

      Now the values are updating correctly! 🙂

      • #7165
        Ico
        Member

        I removed them for post-type post, but not for page. Will try it again, thanks!

    • #7177
      Steve
      Keymaster

      @titidodo– Glad you solved it. The default WordPress custom-fields meta box interferes with saving data. This will be fixed in the next version.

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