Tagged: ,

Viewing 5 reply threads
  • Author
    Posts
    • #1716
      achowell
      Member

      I was creating a date picker field and was wanting to know how the scope is tied to the specific taxonomy I created? Does piklist determine this based on the taxonomy created in the plugin?

      // Date Picker for Deadline
       piklist('field', array(
       'type' => 'datepicker'
       ,'scope' => 'taxonomy'
       ,'field' => 'date_needed'
       ,'label' => 'Date Needed'
       ,'description' => 'Click in box'
       ,'required' => true
       ,'attributes' => array(
         'class' => 'text'
       )
      ,'options' => array(
         'dateFormat' => 'M d, yy'
         ,'firstDay' => '0'
      )
      ));

      I created a taxonomy called deadline how do I save under that?

    • #1717
      Steve
      Keymaster

      @achowellFrom our user guide:

      For most situations you do not have to define “scope”. Piklist will do it automatically for you.

      Piklist allows you to mix-and-match field types within a form. So, one form can have fields that save information as post_meta, while other fields save to a taxonomy. Scope is what determines where the field data is saved. If you don’t set the scope parameter then it will default to where the field is used. For example, if you are creating a metabox, then scope will automatically be set to post_meta.

    • #1722
      r.cespa
      Member

      I have a similar problem: I need to save some data in a taxonomy term but I do not know how to specify what taxonomy should be used.

      I noticed that naming the field like the taxonomy, the term is saved in wp_terms table but the relationship between taxonomy term and post is not saved anywhere.
      Any hint on this?

    • #1724
      Steve
      Keymaster

      @r.cespa– Are you trying to save a taxonomy from the edit posts screens, or the edit taxonomy screen? Do you have any code you can post?

    • #1731
      r.cespa
      Member

      @Steve

      Sorry for the delay: I created the CPT and the custom taxonomy using piklist; I’m trying to save data from CPT edit screen into the custom taxonomy.

      
      <?php
      include('piklist-field-addons.php');
      
      add_filter('piklist_post_types', 'WPT_post_type');
      add_filter('piklist_taxonomies', 'WPT_type_tax');
      
      function WPT_post_type($post_types)
      {
              $post_types['offer'] = array(
                      'labels' => piklist('post_type_labels', 'Offerta'),
                      'public' => true,
                      'rewrite' => array(
                              'slug' => 'offerta'
                      ),
                      'supports' => array(
                              'title', 
                              'editor', 
                              'thumbnail', 
                              'excerpt', 
                              'custom-fields', 
                              'revisions'
                      ),
                      'hide_meta_box' => array(
                              'author',
                              'revisions',
                              'comments',
                              'commentstatus'
                      )       
              );
              return $post_types;
      }
      
      function WPT_type_tax($taxonomies) 
      {
              $taxonomies[] = array(
                      'post_type' => 'offer',
                      'name' => 'departureCity',
                      'show_admin_column' => true,
                      'hide_meta_box' => false,
                      'configuration' => array(
                              'hierarchical' => false,
                              'labels' => piklist('taxonomy_labels', 'Aeroporto di Partenza'),
                              'show_ui' => true,
                              'query_var' => true,
                              'rewrite' => array( 
                                      'slug' => 'aeroporto-di-partenza' 
                              )
                      )
              );
       
              return $taxonomies;
      }
      

      And in parts/meta-boxes/test.php I put:

      
      piklist('field', array(
              'type' => 'group',
              'label' => 'Prezzi',
              'field' => 'prezzi',
      //      'add_more' => true,
              'fields' => array (
                              array(
                                      'type' => 'datepicker',
                                      'field' => 'departureDate',
                                      'label' => 'Data di partenza',
                                      'columns' => 6,
                              ),
                              array(
                                      'columns' => 6,
                                      'scope' => 'taxonomy',
                                      'type' => 'text',
                                      'field' => 'departureCity',
                                      'label' => 'Citt&agrave; di partenza',
                                      'description' => 'Terms will appear when they are added to this taxonomy.',
                              )
                      )
              ) 
      );
      

      I can see the taxonomy meta-box on the edit screen and I can see the text field created by Piklist; if I put some text in that field, the term is saved to the database but it is not showed on the next refresh of the screen and is not added as a term in the “standard” meta-box. I tried saving draft, publishing, etc.

      Any suggestion?

    • #1734
      Steve
      Keymaster

      @r.cespa– Piklist doesn’t create the default taxonomy meta boxes that WordPress has, so this might not work the way you want. Right now converted existing terms to a checkbox or radio button list is the way to go.

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