PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] Displays the total number of products

 March 02, 2022     html, php, woocommerce, wordpress     No comments   

Issue

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


Solution

In case you want 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 returns the total number of published products in your store.



Answered By - Deep Kakkar
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing