Show Product Number of Dokan Seller in Single Product Page

Recently I was working on a project where On single Product page I had to show some in-depth information of the Seller/vendor.
I want to show the number of product listed by that products seller. I used Elementor as page builder so that I created a shortcode to solve the issue. I am sharing the code here so that you can use if needed.

1. I hope you are already have a child theme installed. Add this code in functions.php of your child theme.

function wpdivine_vendor_products_count(){
	
	$user_id = get_the_author_meta('ID');
    $args = array( 
     'post_type' => 'product', 
    'post_status' => 'publish', 
   	'author'   => $user_id,
	'poscccts_per_page' => -1 
    );
    $products = new WP_Query( $args );
    return " " . $products->found_posts . " Available Listings";
}
add_shortcode( 'wd_vendor_products_count', 'wpdivine_vendor_products_count' );


2. Add the Shortcode [wd_vendor_products_count] where you want to show the data.
3. Enjoy & let me know if you have any questions.

Leave a Comment

Your email address will not be published. Required fields are marked *