Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can’t count users CPTs inside bp-custom.php


  • marcelo2605
    Participant

    @marcelo2605

    I will use this information to decide if a new nav item wil be showed or not.

    I try this three alternatives. But none of them works.

    
    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 );
    }
    
    $post_count = count_user_posts_by_type( 1, "movie" );
    
    $post_count = count_user_posts_by_type( array(1), "movie", true );
    
    $post_count = count_user_posts( 1 , "movie"  );

    This codes works only with post.

  • You must be logged in to reply to this topic.
Skip to toolbar