Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_count_many_users_posts

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
671       * by the user ID.
672       *
673       * @since 6.8.0
674       *
675       * @param string[]|null   $count       The post counts. Return a non-null value to short-circuit.
676       * @param int[]           $users       Array of user IDs.
677       * @param string|string[] $post_type   Single post type or array of post types to check.
678       * @param bool            $public_only Whether to only return counts for public posts.
679       */
680      $pre = apply_filters( 'pre_count_many_users_posts', null, $users, $post_type, $public_only );
681      if ( null !== $pre ) {
682           return $pre;
683      }
684
685      $userlist = implode( ',', array_map( 'absint', $users ) );
686      $where    = get_posts_by_author_sql( $post_type, true, null, $public_only );
687
688      $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
689