Using shortcodes for products
WooCommerce provides various built-in shortcodes to display product information. The [product] shortcode is one of the available shortcodes for this. These shortcodes are handled by the class-wc-shortcodes.php file of WooCommerce. This shortcode supports various attributes, such as limit, columns, IDs, and category. You can find all the available attributes at https://docs.woocommerce.com/document/woocommerce-shortcodes/.
In this case, we only used the ids attribute to specify the products we want to display on the page. Once the shortcode is viewed on the frontend, WooCommerce will query the wp_posts table in the database for products with specified IDs. Then, it will generate the HTML for products to be displayed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access