Support » Fixing WordPress » How to output a custom taxonomy term ?

  • Hello,

    I know how to echo the name, id or description of a taxonomy, but how to echo a custom field of a taxonomy ?

    My custom term looks like that:

    add_action( 'albums_add_form_fields', 'albums_taxonomy_add_new_meta_field', 10, 2 );
    function albums_taxonomy_edit_meta_field($term) {
    	// put the term ID into a variable
    	$t_id = $term->term_id;
    	// retrieve the existing value(s) for this meta field. This returns an array
    	$term_meta = get_option( "taxonomy_$t_id" ); ?>
    	<tr class="form-field">
    	<th scope="row" valign="top"><label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'albums' ); ?></label></th>
    			<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="<?php echo esc_attr( $term_meta['custom_term_meta'] ) ? esc_attr( $term_meta['custom_term_meta'] ) : ''; ?>">
    			<p class="description"><?php _e( 'Enter a value for this field','albums' ); ?></p>

    Thank you !

  • The topic ‘How to output a custom taxonomy term ?’ is closed to new replies.