Hướng dẫn chèn khung soạn thảo đầy đủ cho Top Content và Bottom Content danh mục sản phẩm Flatsome bằng code


Cách 1: Thêm Đoạn Mã Vào File functions.php

add_action('init', function () {
remove_action('product_cat_edit_form_fields', 'top_text_taxonomy_edit_meta_field', 10);
remove_action('product_tag_edit_form_fields', 'top_text_taxonomy_edit_meta_field', 10);
remove_action('product_cat_edit_form_fields', 'bottom_text_taxonomy_edit_meta_field', 10);
remove_action('product_tag_edit_form_fields', 'bottom_text_taxonomy_edit_meta_field', 10);

add_action('product_cat_edit_form_fields', 'wp_editor_top', 10, 2);
add_action('product_tag_edit_form_fields', 'wp_editor_top', 10, 2);
add_action('product_cat_edit_form_fields', 'wp_editor_bottom', 10, 2);
add_action('product_tag_edit_form_fields', 'wp_editor_bottom', 10, 2);
});

function wp_editor_top($term) {
$meta = get_term_meta($term->term_id, 'cat_meta', true);
$content = isset($meta['cat_header']) ? $meta['cat_header'] : '';
echo '<tr class="form-field"><th><label for="term_meta[cat_header]">Top Content</label></th><td>';
wp_editor($content, 'term_meta_cat_header', ['textarea_name' => 'term_meta[cat_header]', 'media_buttons' => true, 'textarea_rows' => 10]);
echo '</td></tr>';
}

function wp_editor_bottom($term) {
$meta = get_term_meta($term->term_id, 'cat_meta', true);
$content = isset($meta['cat_footer']) ? $meta['cat_footer'] : '';
echo '<tr class="form-field"><th><label for="term_meta[cat_footer]">Bottom Content</label></th><td>';
wp_editor($content, 'term_meta_cat_footer', ['textarea_name' => 'term_meta[cat_footer]', 'media_buttons' => true, 'textarea_rows' => 10]);
echo '</td></tr>';
}
Lưu lại và thử nghiệm

Cách 2: Soạn thảo sẵn rồi dán nội dung dạng đoạn mã vào Top Content và Bottom Content danh mục sản phẩm