i add some custom meta field to product taxonomy "artist" they work well and save to taxonomy
/**
add meta data to artist taxonomy */
function artist_add_meta_fields( $taxonomy ) {
?>
<div class="form-field term-group">
<label for="artist_nickname"><?php _e( 'Nickname', 'my-plugin' ); ?></label>
<input type="text" id="artist_nickname" name="artist_nickname" />
</div>
<?php
}
add_action( 'artist_add_form_fields', 'artist_add_meta_fields', 10, 2 );
function artist_edit_meta_fields( $term, $taxonomy ) {
$artist_nickname = get_term_meta( $term->term_id, 'artist_nickname', true );
?>
<tr class="form-field term-group-wrap">
<th scope="row">
<label for="artist_nickname"><?php _e( 'Nickname', 'my-plugin' ); ?></label>
</th>
<td>
<input type="text" id="artist_nickname" name="artist_nickname" value="<?php echo $artist_nickname; ?>" />
</td>
</tr>
<?php
}
add_action( 'artist_edit_form_fields', 'artist_edit_meta_fields', 10, 2 );
function artist_save_taxonomy_meta( $term_id, $tag_id ) {
if( isset( $_POST['artist_nickname'] ) ) {
update_term_meta( $term_id, 'artist_nickname', esc_attr( $_POST['artist_nickname'] ) );
}
}
add_action( 'created_artist', 'artist_save_taxonomy_meta', 10, 2 );
add_action( 'edited_artist', 'artist_save_taxonomy_meta', 10, 2 );
but i cant get them in taxonomy-artist.php in frontend
//Get Taxonomy Meta
$artist_nickname = get_term_meta($term->term_id,'artist_nickname');
echo $artist_nickname;
but nothing displayed. where is my problem?