custom-metadata icon indicating copy to clipboard operation
custom-metadata copied to clipboard

Make "value" attributes filterable

Open joshbetz opened this issue 12 years ago • 4 comments

People might want to filter the value attribute so that they can store the ID instead of the slug for taxonomy_checkbox fields, for example

joshbetz avatar Nov 27 '13 04:11 joshbetz

Since it looks like you can pass in values to the fields that don't save as arrays, this would only effect multi_select, taxonomy_checkbox, and taxonomy_multi_select. By default, these all use the slug. Something like apply_filters( 'custom_metadata_value', $slug, $field ) should give enough context to be used for all three of these. Since the slug is a unique key, you should be able to query against it to get the ID pretty easily.

joshbetz avatar Nov 27 '13 14:11 joshbetz

Is there a reason a user would want to manage the output via filters versus another option for the field type?

hardlyneutral avatar Nov 27 '13 14:11 hardlyneutral

It gives you more control. Instead of choosing between slug and ID, you can make the value whatever you want. It's also not ideal to add more parameters.

joshbetz avatar Nov 27 '13 16:11 joshbetz

Cool. Is someone looking at adding that or did you need me to take a crack at it?

hardlyneutral avatar Nov 27 '13 16:11 hardlyneutral