Skip to content

Instantly share code, notes, and snippets.

@benhuson
Created July 11, 2012 14:09
Show Gist options
  • Save benhuson/3090587 to your computer and use it in GitHub Desktop.
Save benhuson/3090587 to your computer and use it in GitHub Desktop.
Term Taxonomy meta example
/**
* Add extra category fields
* Requires the Term_Taxonomymeta plugin
*/
function add_category_excerpt_fields( $category ) {
if ( ! class_exists( 'Term_Taxonomymeta' ) )
return;
$category_metadata = get_metadata( 'term_taxonomy', $category->term_id, 'excerpt', true );
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="excerpt"><?php _e( 'Excerpt' ) ?></label></th>
<td>
<textarea rows="3" cols="40" name='excerpt' id='excerpt_input'><?php echo $category_metadata; ?></textarea>
</td>
</tr>
<?php
}
/**
* Save extra category fields
* Requires the Term_Taxonomymeta plugin
*/
function save_category_excerpt_fields( $term_id ) {
if ( class_exists( 'Term_Taxonomymeta' ) ) {
if ( isset( $_POST['excerpt'] ) ) {
$category_metadata = wp_kses_post( $_POST['excerpt'] );
update_metadata( 'term_taxonomy', $term_id, 'excerpt', $category_metadata );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment