Daniel C
Daniel C

Reputation: 31

How to use a WooCommerce shortcode as PHP code

How can use this WooCommerce shortcode in PHP:

[products columns="3" attribute="ir" terms="20" orderby="date"]

Any help on this?

Upvotes: 2

Views: 4451

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253814

Inside any PHP code, use dedicated WordPress function do_shortcode() as follow:

echo do_shortcode("[products columns='3' attribute='ir' terms='20' orderby='date']");

or inserting that on the html code from a php file:

<?php echo do_shortcode("[products columns='3' attribute='ir' terms='20' orderby='date']"); ?>

It will work on your php code.

Upvotes: 3

Related Questions