php - WooCommerce: show featured product on homepage
one text
I want to show our featured product (we have only one) on the homepage through a shortcode. I know there is a WooCommerce shortcode [featured_products]
to shows a product list, but I want to show more information than this shortcode gives me. In the shortcode I'm only getting:
- Product image
- Product name
- Price
- Add to cart
But I would want to show a few more things
- Product image
- Product name
- Tags
- Categories
- Price
- Add to cart
I managed to get this by using the [product_page]
shortcode, because that shows a lot more information. By adding the SKU 'featured' to the product I want to show, adding the shortcode [product_page sku="featured"]
to the homepage and doing some CSS work, this works like a charm.
The problem now is that all of the client's products have a unique SKU (of course). So I can't use that featured SKU to display the featured product :(.
So I'm seeing two options
- Extending the
[featured_products]
shortcode so it can show tags and categories - Keep the
[product_page]
shortcode, but have to possibility to filter on featured products. So basically adding the attributevisibility="featured"
to[product_page]
(now this only works on the[products]
shortcode).
Is there anybody who can assist me with this, please? Very much appreciated!
Source