wpseek.com
WordPress开发者和主题制作者的搜索引擎
count_many_users_posts › WordPress Function
Since3.0.0
已弃用n/a
› count_many_users_posts ( $users, $post_type = 'post', $public_only = false )
参数: (3) |
|
返回: |
|
定义在: |
|
文档: |
Gets the number of posts written by a list of users.
Related Functions: count_user_posts, count_users, wp_count_posts, get_usernumposts, get_all_user_settings
源码
function count_many_users_posts( $users, $post_type = 'post', $public_only = false ) { global $wpdb; $count = array(); if ( empty( $users ) || ! is_array( $users ) ) { return $count; } $userlist = implode( ',', array_map( 'absint', $users ) ); $where = get_posts_by_author_sql( $post_type, true, null, $public_only ); $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); foreach ( $result as $row ) { $count[ $row[0] ] = $row[1]; } foreach ( $users as $id ) { if ( ! isset( $count[ $id ] ) ) { $count[ $id ] = 0; } } return $count; }