Накопировал все подряд из разных мест, а $term_id = $term->term_id и $term->ID, которое получилось из $post->ID, это две большие разницы, сейчас сохраняется, оставляю шпаргалку другим, кому надо tinyMCE поле, ну и конечно для себя в будущем, я часто заглядываю в свои же вопросы-ответы
add_action( 'product_cat_add_form_fields', 'cxc_taxonomy_add_new_meta_field', 10, 2 );
function cxc_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="custom_term_meta"><?php _e( 'Custom meta field', 'cxc-codexcoach' ); ?></label>
<!--<input type="text" name="custom_term_meta" id="custom_term_meta" value="">-->
<?php
$term_id = $term->term_id;
wp_editor(get_term_meta( $term_id, 'custom_term_meta', true ), 'custom_term_meta', array(
'wpautop' => 1,
'media_buttons' => 1,
'textarea_name' => 'custom_term_meta',
'textarea_rows' => 5,
'tabindex' => null,
'editor_css' => '<style>.quicktags-toolbar, .wp-editor-tools, .wp-editor-wrap, .wp-switch-editor {padding: 5px 10px;}</style>',
'editor_class' => 'form-field tinyeditor',
'teeny' => 0,
'dfw' => 0,
'tinymce' => 1,
'quicktags' => 1,
'drag_drop_upload' => false
) );?>
<p class="description"><?php _e( 'Enter a value for this field','cxc-codexcoach' ); ?></p>
</div>
<?php
}
add_action( 'product_cat_edit_form_fields', 'cxc_taxonomy_edit_meta_field', 10, 2 );
function cxc_taxonomy_edit_meta_field( $term ) {
// put the term ID into a variable
$term_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_term_meta( $term_id, 'custom_term_meta', true ); ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="custom_term_meta"><?php _e( 'Example meta field', 'cxc-codexcoach' ); ?></label></th>
<td>
<!--<input type="text" name="custom_term_meta" id="custom_term_meta" value="<?php echo ( !empty($term_meta) ) ? $term_meta : ''; ?>">-->
<?php
wp_editor(get_term_meta( $term_id, 'custom_term_meta', true ), 'custom_term_meta', array(
'wpautop' => 1,
'media_buttons' => 1,
'textarea_name' => 'custom_term_meta',
'textarea_rows' => 5,
'tabindex' => null,
'editor_css' => '<style>.quicktags-toolbar, .wp-editor-tools, .wp-editor-wrap, .wp-switch-editor {padding: 5px 10px;}</style>',
'editor_class' => 'form-field tinyeditor',
'teeny' => 0,
'dfw' => 0,
'tinymce' => 1,
'quicktags' => 1,
'value' => TRUE,
'drag_drop_upload' => false
) );?>
<p class="description"><?php _e( 'Enter a value for this field','cxc-codexcoach' ); ?></p>
</td>
</tr>
<?php
}
add_action( 'edited_product_cat', 'cxc_save_taxonomy_custom_meta', 10, 2 );
add_action( 'create_product_cat', 'cxc_save_taxonomy_custom_meta', 10, 2 );
function cxc_save_taxonomy_custom_meta( $term_id ) {
if ( isset( $_POST['custom_term_meta'] ) && !empty( $_POST['custom_term_meta'] ) ) {
update_term_meta( $term_id, 'custom_term_meta', $_POST['custom_term_meta'] );
}
}