taxonomy - Creating pre-defined taxonomies in WordPress -
i’m creating wordpress plugin, in turn creates custom post type mma fighters. want organise fighters weight class, though use of custom taxonomy.
i’ve created weight class taxonomy this:
<?php register_taxonomy('mma_weight_class', 'mma_fighter', array( 'hierarchical' => false, 'label' => __('weight class'), 'query_var' => true, 'rewrite' => true ));
however, doesn’t seem yield quite want. when go add/edit fighter post, there’s weight class panel displays following:
what i’d instead weight class panel that, options (i.e. lightweight, middleweight, heavyweight etc) predefined plugin , displayed drop-down list, rather open input above user can add ol’ option.
is possible create pre-defined options taxonomy this?
update
so, found wp_insert_term() function, programmatically added weight classes, , changed hierarchical
true
in taxonomy definition. gets me closer want, have this:
however, i’d rather radios instead of checkboxes (so users select 1 weight class), , “+ add new category” option wasn’t available, want users choose pre-defined options , not able create own.
the metabox looking because defined 'hierarchical' => false
argument, if set 'hierarchical' => true
it'll adopt categories style metabox, checkboxes think don't wanna give oportunity users create sub-categories, because wrong.
you have 3 approaches here:
1) set 'hierarchical' => true
enable fighter on more 1 class
2) change default metabox custom post type, replacing checkboxes radio buttons
3) create custom metabox, radio buttons too
sorry bad english
Comments
Post a Comment