• I am fetching the total number of posts created by users using the following function:

    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 );
    }
    The issue is that it is not counting the Co-authored posts for the custom post type.

    More information :
    I have created a page template which runs a WP_User loop for a user role. For each user I need to fetch the total number of custom post types created by the user for which the above function is called for every user.

    Now, the function filter_count_user_posts should run on get_usernumposts filter, but it seems it is not working as expected. Any help/suggestions are welcome.

    Also posted here : https://github.com/Automattic/Co-Authors-Plus/issues/231

    https://wordpress.org/plugins/co-authors-plus/

  • The topic ‘filter_count_user_posts not running on get_usernumposts filter’ is closed to new replies.