谢谢你的帮助。我最终在另一个地方找到了帮助,现在我正在函数中使用这些函数。php:
// A callback function to add a custom field to our "presenters" taxonomy
function presenters_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you\'re editing
$t_id = $tag->term_id; // Get the ID of the term you\'re editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="abreviatura"><?php _e(\'Abreviatura\'); ?></label>
</th>
<td>
<input type="text" name="term_meta[abreviatura]" id="term_meta[abreviatura]" size="25" style="width:60%;" value="<?php echo $term_meta[\'abreviatura\'] ? $term_meta[\'abreviatura\'] : \'\'; ?>"><br />
<span class="description"><?php _e(\'Abreviatura del tipo de tarea\'); ?></span>
</td>
</tr>
<?php
}
// A callback function to save our extra taxonomy field(s)
function save_taxonomy_custom_fields( $term_id ) {
if ( isset( $_POST[\'term_meta\'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_term_$t_id" );
$cat_keys = array_keys( $_POST[\'term_meta\'] );
foreach ( $cat_keys as $key ){
if ( isset( $_POST[\'term_meta\'][$key] ) ){
$term_meta[$key] = $_POST[\'term_meta\'][$key];
}
}
//save the option array
update_option( "taxonomy_term_$t_id", $term_meta );
}
}
// Add the fields to the "presenters" taxonomy, using our callback function
add_action( \'tipo_de_tarea_edit_form_fields\', \'presenters_taxonomy_custom_fields\', 10, 2 );
// Save the changes made on the "presenters" taxonomy, using our callback function
add_action( \'edited_tipo_de_tarea\', \'save_taxonomy_custom_fields\', 10, 2 );
我用以下代码调用代码:
<?php
$terms = get_the_terms( $post->ID, \'tipo_de_tarea\' );
if ($terms && !is_wp_error($terms)):
foreach($terms as $term): ?>
<a href="<?php echo get_term_link( $term->slug, \'tipo_de_tarea\'); ?>" rel="tag" class="<?php echo $term->slug; ?>" title="<?php echo $term->name; ?>"><?php echo $term->abreviatura; ?></a>
<?php
endforeach;
endif;
?>
但函数有一些问题,我只看到一个空白列。。。
有人知道问题出在哪里吗?
谢谢