正在查看 1 個帖子:1-1 (共 1 個帖子)
-
作者帖子
-
還是為博客互動活躍度考慮,顯示效果如下
function get_author_comments_count( $atts ) { global $wpdb; $author_id = get_post_field( 'post_author' ); // 獲取當前文章作者 ID $comments_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = %d", $author_id, 1 ) ); $replies_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = %d AND comment_parent != %d", $author_id, 1, 0 ) ); $output = " 作者共有 {$comments_count} 條評論和 {$replies_count} 條回覆"; return $output; } add_shortcode( 'author_comments_count', 'get_author_comments_count' );
在文章中使用 [author_comments_count] 簡碼即可。
-
作者帖子
正在查看 1 個帖子:1-1 (共 1 個帖子)
- 哎呀,回覆話題必需登錄。