sc_product post type in the query.
Simple Query Example
Here is a query example. To query the posts, you will need to specifysc_product as the post type.
php
Querying Product Posts
This will return a posts query. You can show the the title (the product name) and the excerpt (the product description) for example.php
Getting Product Data From The Post
However, you will likely want to display the product data, such as the price amount, whether it is out of stock, and more. You can do that in several ways.In the loop
Since we are already in the loop, and have called$products->the_post(), you can use sc_get_product() to fetch the current posts’ product:
php
Outside the loop
However, if you are not in the loop, you can still use the sc_get_product function, and pass a post or post id:Full Example
php
Querying Variant Options
You can also query by a variant option or multiple variant options by using thevariant_options parameter.
Querying a single variant option
Querying products by option:Querying multiple variant options
When querying multiple variant options, you will want to pass arelation argument, to let the query know if these options are inclusive or exclusive.
Here’s an example to get products that are small and orange.