Guest User

Untitled

a guest
Dec 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2. // Save extra taxonomy fields callback function.
  3. function save_taxonomy_custom_meta( $term_id ) {
  4. if ( isset( $_POST['term_meta'] ) ) {
  5. $t_id = $term_id;
  6. $cat_keys = array_keys( $_POST['term_meta'] );
  7. $new_meta = array();
  8. foreach ( $cat_keys as $key ) {
  9. if ( isset ( $_POST['term_meta'][$key] ) ) {
  10. $new_meta[$key] = $_POST['term_meta'][$key];
  11. }
  12. }
  13. // Save the option array.
  14. update_option( "taxonomy_$t_id", $new_meta );
  15. }
  16. }
  17. add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 2 );
  18. add_action( 'create_category', 'save_taxonomy_custom_meta', 10, 2 );
Add Comment
Please, Sign In to add comment