title: WordPress: count custom fields values and echo the number
body: <p>Was looking around for a while and couldn't find a solution. So my question is:</p>
  
  <p>I have a custom field (checkbox), for example: <code>my_custom_field_checkbox</code>. And I have 5 posts that have this checkbox checked. I need to get that number five somehow to use it in the front end, for example:</p>
  
  <p><strong>Admin:</strong></p>
  
  <p>[checkbox] I read this book</p>
  
  <p><strong>Front end:</strong></p>
  
  <p>People who read that book (<strong>5</strong>)</p>
  
  <p>So, how could I do that? Thank you!</p>
  
  <h2>EDIT:</h2>
  
  <hr>
  
  <p>Ok, I was examing this question and googling and I came up with that code, it works, and it allows me to count different values of the same custom field:</p>
  
  <pre><code>$rbBuildCatsArray = array('cat_top_managers_args'=&gt;__('Top management, managers','ibchrrb'),'cat_car_business_args'=&gt;__('Car Business','ibchrrb'),'administrative_staff'=&gt;__('Administrative staff','ibchrrb'),'banks_insurance_leasing'=&gt;__('Banks, insurance, leasing','ibchrrb'),'safety_guard'=&gt;__('Safety, guard','ibchrrb'),'accounting_finance_enterprise_economy'=&gt;__('Accounting, finance, enterprise economy','ibchrrb'),'public_service_nonprofit_organizations'=&gt;__('Public service, non-profit organizations','ibchrrb'),'design_art_entertainment'=&gt;__('Design, art, entertainment','ibchrrb'),'home_staff_service'=&gt;__('Home staff, service','ibchrrb'),'procurement_supply_fea'=&gt;__('Procurement, supply, FEA','ibchrrb'),'internet_it_telecom_communication'=&gt;__('Internet, IT, telecom, communication','ibchrrb'),'logistics_transport_storage'=&gt;__('Logistics, transport, storage','ibchrrb'),'marketing_advertising_pr'=&gt;__('Marketing, Advertising, PR','ibchrrb'),'healthcare_jobs'=&gt;__('Healthcare Jobs','ibchrrb'),'science_education_consulting'=&gt;__('Science, education, consulting','ibchrrb'),'hr_department_hr_training'=&gt;__('HR department, HR, training','ibchrrb'),'part_time_seasonal_work'=&gt;__('Part-time, seasonal work','ibchrrb'),'sales'=&gt;__('Sales','ibchrrb'),'industry_agriculture'=&gt;__('Industry, agriculture','ibchrrb'),'jobs_for_youth'=&gt;__('Jobs for Youth','ibchrrb'),'workmen_laborers'=&gt;__('Workmen, laborers','ibchrrb'),'restaurateurs_chefs_waiters'=&gt;__('Restaurateurs, chefs, waiters','ibchrrb'),'retail_trade'=&gt;__('Retail, trade','ibchrrb'),'media_publishing_printing'=&gt;__('Media, publishing, printing','ibchrrb'),'sports_fitness_beauty_salons'=&gt;__('Sports, fitness, beauty salons','ibchrrb'),'real_estate'=&gt;__('Real estate','ibchrrb'),'tourism_hotels'=&gt;__('Tourism, hotels','ibchrrb'),'services_repair_and_maintenance'=&gt;__('Services, repair and maintenance','ibchrrb'),'jurisprudence'=&gt;__('Jurisprudence','ibchrrb'));
  
   foreach($rbBuildCatsArray as $category=&gt;$label){
      $unqCatVariable = '$cat_'.$category.'_args';
      $unqCatVariableCount = '$cat_'.$category.'_count';
  
     $unqCatVariable = array('post_type' =&gt; 'paibcresume','posts_per_page' =&gt; -1,'meta_query'=&gt;array(),'meta_key' =&gt; '');
     $unqCatVariable['meta_query'][] = array('key'=&gt;'rbwwcategoryhidden','value'=&gt;$label,'compare'=&gt;'LIKE');
     $unqCatVariableCount = new WP_Query($unqCatVariable);
  
     echo '&lt;div&gt;' . $label . ' ' . $unqCatVariableCount-&gt;post_count . '&lt;/div&gt;';
   }
  </code></pre>
  
  <h2>EDIT:</h2>
  
  <hr>
  
  <p>Heres the screenshot of what I was talking about. I have custom field in my custom post type. I get values of that custom field and count them <strong>(pink area).</strong></p>
  
  <p><img src="https://i.stack.imgur.com/AMhwL.jpg" alt="enter image description here"></p>