add_action( 'product_cat_edit_form_fields', 'sitiweb_add_term_fields' );
function sitiweb_add_term_fields( $taxonomy ) {
echo '<div class="form-field">
<label for="sitiweb-text">Onderkant pagina</label>
<textarea name="sitiweb-text" id="sitiweb-text" rows="5" cols="40"></textarea>
<p>Beschrijving onderkant van de pagina.</p>
</div>';
}
add_action( 'product_cat_edit_form_fields', 'sitiweb_edit_term_fields', 10, 2 );
function sitiweb_edit_term_fields( $term, $taxonomy ) {
$value = get_term_meta( $term->term_id, 'sitiweb-text', true );
echo '<tr class="form-field">
<th>
<label for="sitiweb-text">Onderkant pagina</label>
</th>
<td>
<textarea name="sitiweb-text" id="sitiweb-text" rows="5" cols="40">' . esc_attr( $value ) .'</textarea>
<p class="description">Beschrijving onderkant van de pagina.</p>
</td>
</tr>';
}
add_action( 'edited_product_cat', 'sitiweb_save_term_fields' );
add_action( 'create_product_cat', 'sitiweb_save_term_fields' );
function sitiweb_save_term_fields( $term_id ) {
$allowed_html = [
'a' => [
'href' => [],
'title' => [],
],
'br' => [],
'em' => [],
'strong' => [],
'h1' => [],
'h2' => [],
'h3' => [],
'h4' => [],
'p' => [],
];
$note = wp_kses( stripslashes($_POST[ 'sitiweb-text' ]), $allowed_html );
update_term_meta(
$term_id,
'sitiweb-text',
$note
);
}
add_action('woocommerce_after_main_content','sitiweb_under_archive');
function sitiweb_under_archive(){
if( is_product_category() ) {
echo get_term_meta(get_queried_object()->term_id,'sitiweb-text',true);
}
}