dimanche 1 juin 2014

Creating pre-defined taxonomies in WordPress


Vote count:

0




I’m creating a WordPress plugin, that in turn creates a custom post type for MMA fighters. I want to organise fighters by weight class, so though this would be a good use of a custom taxonomy.


I’ve created a weight class taxonomy like this:



<?php
register_taxonomy('mma_weight_class', 'mma_fighter', array(
'hierarchical' => false,
'label' => __('Weight Class'),
'query_var' => true,
'rewrite' => true
));


However, this doesn’t seem to yield quite what I want. When I go to add/edit a fighter post, there’s a weight class panel that displays like the following:


enter image description here


What I’d like instead is a weight class panel like that, but with options (i.e. Lightweight, Middleweight, Heavyweight etc) predefined by my plugin and displayed as a drop-down list, rather than an open input as above where the user can add any ol’ option.


Is it possible to create pre-defined options for a taxonomy like this?



asked 17 secs ago






Aucun commentaire:

Enregistrer un commentaire