Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created August 27, 2012 15:45
Show Gist options
  • Select an option

  • Save pippinsplugins/3489681 to your computer and use it in GitHub Desktop.

Select an option

Save pippinsplugins/3489681 to your computer and use it in GitHub Desktop.
<?php
// Save extra taxonomy fields callback function.
function save_taxonomy_custom_meta( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$cat_keys = array_keys( $_POST['term_meta'] );
$new_meta = array();
foreach ( $cat_keys as $key ) {
if ( isset ( $_POST['term_meta'][$key] ) ) {
$new_meta[$key] = $_POST['term_meta'][$key];
}
}
// Save the option array.
update_option( "taxonomy_$t_id", $new_meta );
}
}
add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 2 );
add_action( 'create_category', 'save_taxonomy_custom_meta', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment