Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php add_action ( 'edit_category_form_fields', 'extra_category_fields');
  2. //add extra fields to category edit form callback function
  3. function extra_category_fields( $tag ) { //check for existing featured ID
  4. $t_id = $tag->term_id;
  5. $cat_meta = get_option( "category_$t_id");
  6. ?>
  7. <label for="extra3"><?php _e('More field'); ?></label>
  8. <?php $settings = array( 'textarea_name' => 'css[extra3]' ); wp_editor( $cat_meta['extra3'], 'css-extra3',$settings ); ?>
  9. <?php
  10. add_action ( 'edited_category', 'save_extra_category_fileds');
  11. // save extra category extra fields callback function
  12. function save_extra_category_fileds( $term_id ) {
  13. if ( isset( $_POST['css'] ) ) {
  14. $t_id = $term_id;
  15. $cat_meta = get_option( "category_$t_id");
  16. $cat_keys = array_keys($_POST['css']);
  17. foreach ($cat_keys as $key){
  18. if (isset($_POST['css'][$key])){
  19. $cat_meta[$key] = $_POST['css'][$key];
  20. }
  21. }
  22. //save the option array
  23. update_option( "category_$t_id", $cat_meta );
  24. }
  25. }
  26. } ?>
  27.  
  28. <?php $cat_id = Category_ID;
  29. $cat_data = get_option("category_$cat_id");
  30. echo do_shortcode($cat_data['extra3']); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement