asked 8 years ago

Hi, i want to use users question count(not total question) at my sites user profile page (using buddypress).. i can use total question count but i want Users questions, try too many suggest/function code for solved my problem but cant find any solution…

My site:
User Profile Page Example:

i try too many way like thats but cant solved my problem, if anyone have idea please tell


<?php $user_post_count = count_user_posts( $userid , $post_type ); ?>
function count_user_posts_by_type( $userid, $post_type = 'post' ) {
    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 );

this one use post type= dwqa-question but when try "-" show syntx error.. i change some different but still can’t solved..

use this one like;

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);

by the way, i try this wordpress plugin

thats work at backend / admin user list.. but i want to use at users profile page…

Any idea??

1 Answers
answered 8 years ago

Please send me username & password of your site (via private answer) for further checking.

replied 8 years ago

Thanks for reply but i solved my problem no need help anymore, thanks anyway..

Powered by DW Question & Answer Pro