WordPress.org

Ready to get started?Download WordPress

Forums

How to output a custom taxonomy term ? (1 post)

  1. evo252
    Member
    Posted 2 years ago #

    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>
    		<td>
    			<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>
    		</td>
    	</tr>
    <?php
    }

    Thank you !

Topic Closed

This topic has been closed to new replies.

About this Topic