George Pennet George Pennet - 8 months ago 52
PHP Question

Displays the total number of products

What code use to display the total number of products? I want to make a section with icons on the main page of my store and it would be great to include something like that.

Best Regards

Answer Source

In case if you wants to show total number of published products in your store, use the following code:

$args = array( 'post_type' => 'product', 'post_status' => 'publish', 
'posts_per_page' => -1 );
$products = new WP_Query( $args );
echo $products->found_posts;

It sill return total number of published products in your store.