Tagged: custom taxonomy, metabox, taxonomy
- This topic has 8 replies, 2 voices, and was last updated 3 years, 8 months ago by
Steve.
-
AuthorPosts
-
-
May 24, 2018 at 2:36 pm #9016
achowellMemberSo I followed the tutorial to set up a selection box that has my custom taxonomy values, but its not appearing for some reason. The taxonomy is Project Status and the options I added are Open and Close.
Here is the code used to create the taxonomy and hide the original metabox
//Create Project Status Taxonomy add_filter('piklist_taxonomies', 'project_status'); function project_status($taxonomies) { $taxonomies[] = array( 'post_type' => 'mro_project' ,'name' => 'project_status' ,'show_admin_column' => true ,'configuration' => array( 'hierarchical' => true ,'labels' => piklist('taxonomy_labels', 'Project State') ,'hide_meta_box' => true ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'project-status' ) ) ); return $taxonomies; }Here is what is in the file for the selection/dropdown version that is not appearing. This is the only thing in the php file, exactly as is and is located in parts/terms.
piklist('field', array( 'type' => 'select' ,'scope' => 'taxonomy' ,'field' => 'project_status' ,'label' => 'Project Status' ,'description' => 'Change status of project based on amount of people registered' ,'choices' => array( '' => 'Open' ) + piklist(get_terms(array( 'taxonomy' => 'project_status' ,'hide_empty' => false )) ,array( 'term_id' ,'name' ) ) )); -
May 25, 2018 at 12:07 pm #9020
achowellMemberChanged it to the below in the terms folder and still have nothing showing up:
Title: Project Status Description: Change status of project depending on whtether the maximum number of volunteers has been reached. Taxonomy: project_status Capability: manage_options Order: 0 */ piklist('field', array( 'type' => 'select' ,'scope' => 'taxonomy' ,'field' => 'mro_project_status' ,'label' => 'Project Status' ,'description' => 'Change status of project based on amount of people registered' ,'choices' => piklist(get_terms('project_status', array( 'hide_empty' => false, )) , array( 'term_id' , 'name', ) ), )); -
May 25, 2018 at 1:23 pm #9021
-
May 25, 2018 at 1:33 pm #9022
achowellMemberHello Steve, thanks for the reply, the parts/terms is in the plugin, this plugin also creates the mro_project post type through the piklist method. I made some edits to the field code and moved it into the meta box section and it works there. I’m not sure why its not working in the terms folder, but using it in the meta box will work for me, though its now giving me this warning.
Warning: array_column() expects parameter 1 to be array, object given in <plugin_path>/piklist/includes/class-piklist.php on line 2524
-
May 27, 2018 at 8:53 am #9027
SteveKeymasterIf you create a term and edit it, is the field there?
-
May 29, 2018 at 10:44 am #9028
achowellMemberOkay, I was looking for it in the wrong place! Sorry, so I missunderstoopd where this was located. It seems what I wanted was my second solution. A meta-box in the edit section of the post type. I did eventually get the taxonomy drop down on the custom post type edit page, but it does not save on update and it still has that warning message in the meta box.
Warning: array_column() expects parameter 1 to be array, object given in <plugin_path>/piklist/includes/class-piklist.php on line 2524
-
-
May 29, 2018 at 11:08 am #9029
achowellMemberThanks for the help Steve, I removed scope from the code and that solved all of the issues. One last question and you can close this one, how do I set a default selection for the taxonomy dropdown?
-
May 29, 2018 at 10:50 pm #9030
SteveKeymasterGreat. Glad you got it working.
Use the
valueparameter to set the default:
https://piklist.github.io/docs/fields/field-parameters/ -
June 4, 2018 at 4:31 pm #9038
SteveKeymasterClosing this ticket.
-
-
AuthorPosts
- The topic ‘Custom Taxonomy Select Box Missing in Editor’ is closed to new replies.