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 use the following code to count user posts by specific post type:

function count_user_posts_by_type( $userid, $post_type ) {
    global $wpdb;
    $where = get_posts_by_author_sql( $post_type, TRUE, $userid );
    $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
    return apply_filters( 'get_usernumposts', $count, $userid );
}

// Echo Count
echo count_user_posts_by_type( $user_ID, 'reports' );

Looking for an elegant solution to limit posts by dates. For example, last week\month posts.

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.