Last active
August 29, 2015 14:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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