Xin chào các bạn, chắc hẳn một số bạn gặp khó khăn trong quá trình sử dụng trình soạn thảo mới của WordPress, cài thêm plugin sẽ dẫn đến nặng website, hôm nay Digicorp xin chia sẻ cho các bạn một số cách khôi phục lại trình soạn thảo cổ điển trong WordPress nhé.
Dưới đây là “code thay thế plugin Classic Editor” — bạn chỉ cần tạo 1 file plugin nhỏ (hoặc MU-plugin) để tắt Gutenberg và dùng trình soạn thảo cổ điển cho toàn site (cả bài viết, trang, sản phẩm WooCommerce), kèm tùy chọn bật lại “Classic Widgets”.
Cách 1: Tạo MU-plugin (khuyên dùng)
-
Trên hosting, tạo thư mục nếu chưa có:
wp-content/editor-plugins/
-
Tạo file:
wp-content/editor-plugins/disable-gutenberg-classic-editor.php
-
Dán nội dung sau:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?php /** * Plugin Name: Disable Gutenberg & Use Classic Editor * Description: Tắt Block Editor (Gutenberg) và bật Classic Editor + Classic Widgets cho toàn bộ post type (post, page, product...). * Author: Digicorp Media and Technology Group * Version: 1.0.0 * Requires at least: 5.0 */ // —— TẮT BLOCK EDITOR (Gutenberg) CHO MỌI POST TYPE —— add_filter('use_block_editor_for_post_type', '__return_false', 100); add_filter('use_block_editor_for_post', '__return_false', 100); add_filter('gutenberg_can_edit_post_type', '__return_false', 100); // (Tùy chọn) Bật Classic Widgets, tắt trình chỉnh sửa widget dạng block add_filter('use_widgets_block_editor', '__return_false', 100); add_filter('gutenberg_use_widgets_block_editor', '__return_false', 100); // (Tùy chọn) Gỡ CSS của block trên front-end để giảm tải. // Cẩn thận: nếu theme/plugin của bạn cần các style này thì hãy bỏ comment đoạn dưới. /* add_action('wp_enqueue_scripts', function () { wp_dequeue_style('wp-block-library'); wp_dequeue_style('wp-block-library-theme'); wp_dequeue_style('wc-blocks-style'); // nếu dùng WooCommerce Blocks, cân nhắc giữ lại }, 100); */ |
MU-plugin tự kích hoạt ngay, không cần vào Admin để bật.
Cách 2: Dán vào functions.php (hoặc dùng Code Snippets)
Nếu bạn không muốn tạo plugin, có thể dán đoạn dưới vào functions.php của theme con (child theme):
|
1 2 3 4 5 6 7 8 |
// Tắt Gutenberg toàn site add_filter('use_block_editor_for_post_type', '__return_false', 100); add_filter('use_block_editor_for_post', '__return_false', 100); add_filter('gutenberg_can_edit_post_type', '__return_false', 100); // Bật Classic Widgets add_filter('use_widgets_block_editor', '__return_false', 100); add_filter('gutenberg_use_widgets_block_editor', '__return_false', 100); |
Note
Flatsome + WooCommerce: Đoạn code trên áp dụng cả cho product, nên bạn sẽ soạn thảo sản phẩm bằng Classic Editor.
Nếu muốn chỉ tắt Gutenberg cho một vài post type, hãy thay __return_false bằng callback kiểm tra $post_type.
Không cần cài plugin “Classic Editor” hay “Classic Widgets” nữa.

