Skip to content

Instantly share code, notes, and snippets.

@Deaner666
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deaner666/a82755f0350fd9d8d6cc to your computer and use it in GitHub Desktop.
Save Deaner666/a82755f0350fd9d8d6cc to your computer and use it in GitHub Desktop.
Add a custom meta visual editor to the "Edit Term" page of a WooCommerce product_cat
<?php
// Edit term page
add_action( 'product_cat_edit_form_fields', 'wpm_taxonomy_edit_meta_field', 10, 2 );
function wpm_taxonomy_edit_meta_field($term) {
// put the term ID into a variable
$t_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option( "taxonomy_$t_id" );
$content = $term_meta['custom_term_meta'] ? wp_kses_post( $term_meta['custom_term_meta'] ) : '';
$settings = array( 'textarea_name' => 'term_meta[custom_term_meta]' );
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="term_meta[custom_term_meta]"><?php _e( 'Details', 'wpm' ); ?></label></th>
<td>
<?php wp_editor( $content, 'product_cat_details', $settings ); ?>
<p class="description"><?php _e( 'Detailed category info to appear below the product list','wpm' ); ?></p>
</td>
</tr>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment