Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/12fffc123b9503355b7b to your computer and use it in GitHub Desktop.
Save tripflex/12fffc123b9503355b7b to your computer and use it in GitHub Desktop.
custom taxonomy php output options
// Get the custom field taxonomy selected term ID's
$field_value = get_custom_field("outsourcing_partial_type");
if ( is_array( $field_value ) ) {
foreach ( $field_value as $selected_value ) {
$tax = get_term_by( 'id', (int) $selected_value, "outsourcing_partial_type" );
// Set the name of the taxonomy an an item in a new array
$tax_labels[] = $tax->name;
// Or you could just output it in this for loop
echo "<li>" . $tax->name . "</li>";
}
// $tax_labels is now an array of each term label/caption/name
// $csv_tax_labels is now a comma separated string of the name ( taxonomyval1, taxonomyval2, taxonomyval3 ... )
$csv_tax_labels = implode( ', ', $tax_labels );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment