
Những gì bạn có thể thực hiện được thông qua bài viết dưới đây:
- Cách thêm số liệu thống kê số lượng từ bài đăng vào WordPress
- Cột đếm từ quản trị viên
- Hiển thị tổng số từ và hình thu nhỏ của bài đăng
- Cách theo dõi số lượng từ của bạn trong các bài đăng trên WordPress
- Tùy chỉnh các cột quản trị trong WordPress
- Hiển thị số lượng từ của mỗi bài đăng riêng lẻ trong WordPress
1. Cách làm:
Để đạt được điều đó, bạn cần chỉnh sửa tệp functions.php của chủ đề và thêm mã bên dưới.
// Add WordPress WordCount Columnadd_filter(‘manage_posts_columns’, ‘crunchify_add_wordcount_column’);function crunchify_add_wordcount_column($crunchify_columns) {$crunchify_columns[‘crunchify_wordcount’] = ‘Word Count’;return $crunchify_columns;}// Show WordCount in Admin Paneladd_action(‘manage_posts_custom_column’, ‘crunchify_show_wordcount’);function crunchify_show_wordcount($name){global $post;switch ($name){case ‘crunchify_wordcount’:$crunchify_wordcount = crunchify_post_wordcount($post–>ID);echo $crunchify_wordcount;}}// Get individual post word countfunction crunchify_post_wordcount($post_id) {$crunchify_post_content = get_post_field( ‘post_content’, $post_id );$crunchify_final_wordcount = str_word_count( strip_tags( strip_shortcodes($crunchify_post_content) ) );return $crunchify_final_wordcount;}
Leave a Reply