Number format for wp_count_posts()

Question

I’m trying to format my post my total post count in the header of my site. I have the number in there but would like it to format with the commas eg 1,500 not 1500. I know this is probably really basic but I’m still learning.. any help would be much appreciated. Cheers

functions.php

function wpb_total_posts() { 
$total = wp_count_posts()->publish;
echo '' . $total;
} 

Header.php

<?php wpb_total_posts(); ?>
0
Jason 4 months 0 Answers 9 views 0

Leave an answer