Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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)

</div>

</div>

<?php endforeach; ?>
</div>

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

Pardon the HTML mixed in.

share|improve this question

1 Answer 1

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

 
discard

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.