Last active
August 29, 2015 14:13
-
-
Save tripflex/12fffc123b9503355b7b to your computer and use it in GitHub Desktop.
custom taxonomy php output options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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