wp_count_comments

過濾鉤子
apply_filters( 'wp_count_comments', array()
引數
  • (array|stdClass) $count An empty array or an object containing comment counts.
    Required:
  • (int) $post_id The post ID. Can be 0 to represent the whole site.
    Required:
定義位置
相關勾子
wp_insert_commentwp_get_current_commenterpost_comments_linkuntrash_commentwp_list_comments_args
相關方法
wp_count_commentswp_count_attachmentswp_untrash_commentwp_list_commentswp_new_commentwp_count_posts
引入
2.7.0
棄用
-

wp_count_comments 函式是一個 WordPress 核心函式: 這個函式用於計算指定文章的評論數量。它接受文章 ID 作為引數,並返回一個包含評論數量資訊的物件。該物件包含了所有狀態的評論數量,例如已批准的評論數量、未批准的評論數量、垃圾評論數量等。

過濾某一特定文章或整個網站的評論數。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$filtered = apply_filters( 'wp_count_comments', array(), $post_id );
$filtered = apply_filters( 'wp_count_comments', array(), $post_id );
$filtered = apply_filters( 'wp_count_comments', array(), $post_id );

常見問題

FAQs
檢視更多 >