Kích hoạt khung soạn thảo danh mục sản phẩm Flatsome


Thiết kế blogspot cung cấp template blogspot và dịch vụ thiết kế blogspot giá rẻ. Tư vấn thiết kế blogspot miễn phí.
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

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>';
}
4.1/5 - (6 bình chọn)

0 Nhận xét