Viewing 4 reply threads
  • Author
    Posts
    • #7195
      Rob Hust
      Member

      The following code is not saving to the appropriate taxonomies (or anywhere). When the post-type is opened in wordpress, the fields are back to their default, and none of the taxonomy boxes are checked.

      It is saved in “meta-boxes”
      The first two fields are the issue.

      /*
      Title: Recipe Particulars
      Post Type: gw-recipe
      */
      
      piklist( 'field', array(
            'type' => 'select'
            ,'field' => 'gw-cuisine'
            ,'scope' => 'taxonomy'
            ,'label' => 'Choose Cuisine Type'
            ,'columns' => 4
            ,'choices' => array(
              'american' => 'American'
              ,'chinese' => 'Chinese'
              ,'french' => 'French'
              ,'german' => 'German'
              ,'italian' => 'Italian'
              ,'japanese' => 'Japanese'
              ,'mexican' => 'Mexican'
              ,'spanish' => 'Spanish'
              ,'fusion' => 'Fusion'
            	)
            ,'attributes' => array(
            	'multiple' => 'multiple' // This changes a select field into a multi-select field
            	)
      ));
      
      piklist( 'field', array(
            'type' => 'select'
            ,'field' => 'gw-course'
            ,'scope' => 'taxonomy'
            ,'label' => 'Choose Course'
            ,'columns' => 4
            ,'choices' => array(
              'entree' => 'Entree'
              ,'side' => 'Side'
              ,'salad' => 'Salad'
              ,'appetizer' => 'Appetizer'
              ,'breakfast' => 'Breakfast'
              ,'lunch' => 'Lunch'
              ,'supper' => 'Supper'
              ,'snack' => 'Snack'
              ,'dessert' => 'Dessert'
            	)
          	,'attributes' => array(
            		'multiple' => 'multiple' // This changes a select field into a multi-select field
            		)
      ));
      
      piklist( 'field', array(
          	'type' => 'text'
          	,'field' => 'serves'
          	,'label' => __('Serves', 'gw-recipe')
          	,'columns' => 4
          	,'help' => __('Number of servings in the recipe', 'gw-recipe')
          	,'attributes' => array(
            		'class' => 'regular-text'
          		)
          	));
      
      piklist( 'field', array(
          'type' => 'group'
          , 'field' => 'ingredients-add-more'
          ,'add_more' => true
          , 'columns' => 12
          ,'fields' => array(
          	array(
          	'type' => 'text'
          	,'field' => 'quantity'
          	,'label' => __('Quantity', 'gw-recipe')
          	,'columns' => 2
          	,'attributes' => array(
            		'class' => 'regular-text'
          		)
        		),
          	array(
          	'type' => 'text'
          	,'field' => 'measure'
          	,'label' => __('Measure', 'gw-recipe')
          	,'columns' => 3
          	,'attributes' => array(
            		'class' => 'regular-text'
          		)
          	),
          	array(
          	'type' => 'text'
          	,'field' => 'ingredient'
          	,'label' => __('Ingredient', 'gw-recipe')
          	,'columns' => 7
          	,'attributes' => array(
            		'class' => 'regular-text'
          		)
        		)
          )
      ));
      
      piklist( 'field', array(
          'type' => 'group'
          , 'field' => 'instruction-steps'
          ,'add_more' => true
          , 'columns' => 12
          ,'fields' => array(
          	array(
          	'type' => 'text'
          	,'field' => 'instruction_step_num'
          	,'label' => __('Step #', 'gw-recipe')
          	,'columns' => 2
          	,'attributes' => array(
            		'class' => 'regular-text'
          		)
        		),
          	array(
          	'type' => 'textarea',
          	'field' => 'instruction',
          	'label' => 'Instructions',
          	'columns' => 10,
          	'attributes' => array(
            	'rows' => 10,
            	'class' => 'large-text'
          		)
        		)
          )
      ));

      Here’s the definition of the post-type and the taxonomies.

      /*
      Plugin Name: i824 Recipes
      Plugin URI: http://integr824.com/plugin
      Description: This adds recipes post types to WordPress
      Version: 0.1
      Author: Robert Hust
      Author URI: http://integr824.com
      Plugin Type: Piklist
      License: GPL2
      */
      
       if (!defined('ABSPATH'))
        {
          exit;
        }
      
      add_filter('piklist_taxonomies', 'recipe_cuisine');
      function recipe_cuisine($taxonomies){
        $taxonomies[] = array(
          'post_type' => 'gw-recipe'
          ,'name' => 'gw-cuisine'
          ,'show_admin_column' => true
          ,'configuration' => array(
            'hierarchical' => true
            ,'labels' => piklist('taxonomy_labels', 'Cuisines')
            ,'hide_meta_box' => false
            ,'show_ui' => true
            ,'query_var' => true
            ,'rewrite' => array(
              'slug' => 'gw-cuisine'
            )
          )
        );
        return $taxonomies;
      }
      
      add_filter('piklist_taxonomies', 'recipe_course');
      function recipe_course($taxonomies){
        $taxonomies[] = array(
          'post_type' => 'gw-recipe'
          ,'name' => 'gw-course'
          ,'show_admin_column' => true
          ,'configuration' => array(
            'hierarchical' => true
            ,'labels' => piklist('taxonomy_labels', 'Courses')
            ,'hide_meta_box' => false
            ,'show_ui' => true
            ,'query_var' => true
            ,'rewrite' => array(
              'slug' => 'gw-course'
            )
          )
        );
        return $taxonomies;
      }
      
      add_filter('piklist_taxonomies', 'recipe_tools');
      function recipe_tools($taxonomies){
        $taxonomies[] = array(
          'post_type' => 'gw-recipe'
          ,'name' => 'gw-tools'
          ,'show_admin_column' => true
          ,'configuration' => array(
            'hierarchical' => false
            ,'labels' => piklist('taxonomy_labels', 'Tools')
            ,'hide_meta_box' => false
            ,'show_ui' => true
            ,'query_var' => true
            ,'rewrite' => array(
              'slug' => 'gw-course'
            )
          )
        );
        return $taxonomies;
      }
      
      add_filter('piklist_post_types', 'recipe_post_types');
        function recipe_post_types($post_types)
        {
          $post_types['gw-recipe'] = array(
            'labels' => piklist('post_type_labels', 'Recipe')
            ,'title' => __('Enter Recipe Name')
            ,'menu_icon' => piklist('url', 'piklist') . '/parts/img/piklist-menu-icon.svg'
            ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
            ,'supports' => array(
              'title'
              ,'editor'
              ,'excerpt'
              ,'comments'
            )
            ,'public' => true
            ,'admin_body_class' => array(
              'custom-body-class'
            )
            ,'has_archive' => true
            ,'rewrite' => array(
              'slug' => 'gw-recipe'
            )
            ,'capability_type' => 'post'
            ,'edit_columns' => array(
              'title' => __('Recipe')
              ,'author' => __('Assigned to')
            )
          );
          return $post_types;
        }
    • #7196
      Rob Hust
      Member

      I cleaned up the taxonomy definitions, still no joy…

        add_filter('piklist_taxonomies', 'recipe_taxonomies');
        function recipe_taxonomies($taxonomies)
        {
          $taxonomies[] = array(
            'post_type' => 'gw-recipe'
            ,'name' => 'cuisine'
            ,'configuration' => array(
              'hierarchical' => true
              ,'labels' => piklist('taxonomy_labels', 'Cuisine')
              ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
              ,'show_ui' => true
              ,'query_var' => true
              ,'rewrite' => array(
                'slug' => 'cuisine'
              )
              ,'show_admin_column' => true
              ,'list_table_filter' => true
              ,'meta_box_filter' => true
              ,'comments' => true
            )
          );
      
          $taxonomies[] = array(
            'post_type' => 'gw-recipe'
            ,'name' => 'course'
            ,'configuration' => array(
              'hierarchical' => true
              ,'labels' => piklist('taxonomy_labels', 'Course')
              ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
              ,'show_ui' => true
              ,'query_var' => true
              ,'rewrite' => array(
                'slug' => 'course'
              )
              ,'show_admin_column' => true
              ,'list_table_filter' => true
              ,'meta_box_filter' => true
              ,'comments' => true
            )
          );
      
          $taxonomies[] = array(
            'post_type' => 'gw-recipe'
            ,'name' => 'tools'
            ,'configuration' => array(
              'hierarchical' => true
              ,'labels' => piklist('taxonomy_labels', 'Tools')
              ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
              ,'show_ui' => true
              ,'query_var' => true
              ,'rewrite' => array(
                'slug' => 'tools'
              )
              ,'show_admin_column' => true
              ,'list_table_filter' => true
              ,'meta_box_filter' => true
              ,'comments' => true
            )
          );
      
          return $taxonomies;
        }
      
    • #7227
      Steve
      Keymaster

      You can’t allow WordPress to generate the standard taxonomy meta-boxes AND create fields with them as well. You are essentially duplicating inputs which conflict.

      Use 'meta_box_cb' => false when creating the taxonomy to stop the creation of default meta-boxes.

      Explained here >

    • #7247
      Rob Hust
      Member

      You are a fantastic help. I appreciate the time you took to sleuth this out. The post type and taxonomies are working flawlessly – I’ll share a link when it’s deployed.

      I’ve known about Piklist for quite a while, but since my coding skills are lackluster at best, I’ve eschewed it for more GUI focused alternatives – yes, all the usual suspects. The good ones are barely adequate, and train you to accept / deploy mediocre solutions. My dissatisfaction (and far too many annual subscription fees for “developer” licenses) pushed me to finally take the plunge and dive into Piklist. No easy task to be sure, the documentation often has more hints than answers ( typical of a project where the documentation lies in comments in the code itself – where they are not readily accessible or searchable). That is my only real critique, and it will fade in time as my understanding grows.

      You and the community around you have created a fantastic tool. While initially frustrating, it’s becoming more fun and interesting to use as my understanding grows, and with each project. While other’s in the community may argue against you deploying more GUI focussed solutions (and I get it that, now that I’ve climbed the steep side of the learning curve) I respectfully disagree with them. I think with Piklist at the core, your “Toolbox”, and “Fields and Forms” solutions could further enhance the WordPress ecosphere. Unlike your competitors, you have a much more agile and powerful framework. You’ve benefitted from your philosophy of adhering to WordPress standards, while giving us bee-line shortcuts to productivity.

      I offer a heart felt “Thank You” to you and your crew.

    • #7251
      Steve
      Keymaster

      @rhust– So happy you love Piklist! Yes, we know documentation could be better. Honestly, finding it tough because Piklist does so much.

      If you have a few minutes, we would really appreciate it if could leave a review on WordPress.org. It really helps the project.

      Thanks again!

Viewing 4 reply threads
  • The topic ‘Select fields with taxonomy in meta-box not saving.’ is closed to new replies.