WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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