Site icon Hip-Hop Website Design and Development

count & sum the value of custom field of the author post in dynamic posts

I have seen some of the questions and answers here that similar to my case but I can’t seem to understand where I should begin.

What I have so far is the count each the authors post inside the loop.

$author = get_the_author_meta('ID');
$user_post_count = count_user_posts( $author, 'cappers_corner' );
// echo $user_post_count;

Each of the authors post, do have Correct & Wrong radio button where the value return as 1 (for correct) & 0 (for wrong). I need to count how many posts does the author and sum all the checked "correct" radio button and then create a simple formula to display the percentage of their standings. *please see ScreenGrab Figure 1.

sum of the correct will also be displayed as "win" including subtraction to the number of total post for the "loss". *please see ScreenGrab Figure 2.

The formula that I am going to create per author is like this:

sum of correct value from author post / total author post(s) * 100 = value percent

I’m using ACF and Custom Post UI. And the value percentage will be display per author including the standings.

ScreenGrab Figure 1

ScreenGrab Figure 2