After trying a lot of methods for adding products by category using shortcode, i finally found one that worked perfectly for me. You just have to add this in the text editor or anywhere, where you want to show products with the help of shortcode and also for a specific category.
Code:
[[[product_category category="YOUR-CATEGORY-SLUG-HERE" per_page="12" columns="4" orderby="date" order="desc"]]]
So, you will copy this code from here and will paste it to your desired location with your category slug that can be found by navigating to the product menu in your WP admin and clicking on categories where you’ll see a list of all available categories and corresponding slugs.
Where I was needed this code? See below and you will understand
Hope you understand 🙂
Source: https://stackoverflow.com/questions/31018148/shortcode-to-show-products-by-category-woocommerce
Please let me know in comments if you find a better way to do the same task. I’ll be thankfull to you.
Enjoy 🙂