Working on my first WordPress theme, I created a page template for authors based on this tutorial which is itself based on the twenty-fourteen theme.
What I could not understand is this :
$post_count = count_user_posts( $contributor_id );
From this code example.
<?php
// Output the authors list.
$contributor_ids = get_users( array(
'fields' => 'ID',
'orderby' => 'post_count',
'order' => 'DESC',
'who' => 'authors',
));
foreach ( $contributor_ids as $contributor_id ) :
$post_count = count_user_posts( $contributor_id );
// Move on if user has not published a post (yet).
if ( ! $post_count ) {
continue;
}
?>
I have checked the Codex for count_user_posts( )
but it appears that the code is not aligned with the documentation as the output of the foreach loop $contributor_id
is not only the “ID
” but also “post_count
” ,"desc
" and "authors"
.
These are supposed to be the second parameter which is optional is as the Codex specifies below:
$post_type
(array|string) (Optional) Single post type or array of post types to count the number of posts for.
Default value: ‘post’
So how the values of "post_count
" ,"desc
" and “authors
”. fit in the Codex documentation.