I'm almost done, the code below does everything but display post count for each user broken down into post types, and also I'm like to filter it last thirty days.

I'm trying to get the post for each user fr the custom post type 'music'.

<div id="top-artist-wrapper">

<?php foreach ( get_users('orderby=post_count&number=5') as $user ) : ?>

<div class="top-artists">
<?php echo get_avatar($user->ID, '64'); ?>

<div class="artist-name">
    <?php echo $user->display_name; ?> (<?php echo count_user_posts( $user->ID, $post_type='music' ); ?> Posts)



<?php endforeach; ?>

What am I missing, is the even the right way to do the query?

Pardon the HTML mixed in.


count_user_posts() doesn't support the second parameter ($post_type in your code), according to the docs.

There is a function at the bottom of the docs page that allows you do filter by post_type, you could drop in functions.php and use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.