In this tutorial, we discussed how to display woocommerce products with your custom HTML or with a simple layout.
The Basic Code
1 2 3 4 5 6 7 8 9 10 11 12 |
//developers guidance {{urvanov-syntax-highlighter-internal:0}} {{urvanov-syntax-highlighter-internal:1}} {{urvanov-syntax-highlighter-internal:2}} {{urvanov-syntax-highlighter-internal:3}} {{urvanov-syntax-highlighter-internal:4}} {{urvanov-syntax-highlighter-internal:5}} {{urvanov-syntax-highlighter-internal:6}} <p> {{urvanov-syntax-highlighter-internal:7}} </p> {{urvanov-syntax-highlighter-internal:8}} |
Display Woocommerce Products category wise:
The below code help to display the woocommerce products
1 2 |
{{urvanov-syntax-highlighter-internal:0}} {{urvanov-syntax-highlighter-internal:1}} |
You can add more conditions as per the requirement in-display woocommerce products.
‘limit’ => 8, ‘order’ => ‘ASC’, etc
for example :
1 |
{{urvanov-syntax-highlighter-internal:0}}{{urvanov-syntax-highlighter-internal:1}} |
USING ABOVE CODE HOW TO DISPLAY IMAGE, NAME ETC.
Display Image: <?=wp_get_attachment_url($value->image_id );?>
Display Name : <?=(wp_strip_all_tags($value->name), 7, ‘…’?> or <?=$value->name?>
Display Price : <?=$value->price;?>
Product Url : <?=$value->slug?>
Basic Functions to display woocommerce products
- the_title() : Display the product name
- the_excerpt() : Display the brief description about the product
- the_content() : Dispaly the full description of the product
- the_permalink() : Dispay the product URL
- the_post_thumbnail() : Display product image
- the_ID() : Display product ID