Nếu các bạn dùng Plugin Yoast WordPress SEO thì nó sẽ tự động tạo thêm các cột trong admin phần toàn bộ bài viết, toàn bộ page và còn các custom post type khác. Nhìn rất khó chịu vì nó khá tốn diện tích và làm cho phần tiêu đề bị hẹp lại và trở lên kéo dài xuống thật là xấu …
Vậy làm sao để xóa bỏ các cột SEO Title, Meta Desc, Focus KW đó đi?
Xóa bỏ các cột SEO Title, Meta Desc, Focus KW
Thêm đoạn code sau vào file functions.php trong theme của bạn là ok nhé.
/* * Xóa các cột của Yoast SEO trong admin */ function my_columns_filter( $columns ) { //unset($columns['tags']); //unset($columns['comments']); unset($columns['wpseo-title']); unset($columns['wpseo-score']); unset($columns['wpseo-metadesc']); unset($columns['wpseo-focuskw']); unset($columns['wpseo-score-readability']); return $columns; } // Filter Posts add_filter( 'manage_edit-post_columns', 'my_columns_filter',10, 1 ); // Filter pages add_filter( 'manage_edit-page_columns', 'my_columns_filter',10, 1 ); // Custom Post Type add_filter( 'manage_edit-CUSTOMPOSTTYPE_columns', 'my_columns_filter',10, 1 );
Trong đoạn code trên ta có.
unset($columns['wpseo-title']); unset($columns['wpseo-score']); unset($columns['wpseo-metadesc']); unset($columns['wpseo-focuskw']); unset($columns['wpseo-score-readability']);
Đoạn trên là tổng hợp những cột cần xóa bỏ
// Filter Posts add_filter( 'manage_edit-post_columns', 'my_columns_filter',10, 1 );
Dòng trên là xóa cột ở các bài Post
// Filter pages add_filter( 'manage_edit-page_columns', 'my_columns_filter',10, 1 );
Dòng trên là xóa bỏ các cột ở Page
// Custom Post Type add_filter( 'manage_edit-CUSTOMPOSTTYPE_columns', 'my_columns_filter',10, 1 );
Cuối cùng đoạn trên là xóa bỏ tại các custom post type. Thay chữ CUSTOMPOSTTYPE bằng custom post type của bạn là được. Ví dụ custom post type của bạn là product thì bạn thay là
add_filter( 'manage_edit-product_columns', 'my_columns_filter',10, 1 );
Kết quả
Chúc các bạn thành công!
- Bình luận