Search code examples
phpwordpresswoocommerceshortcode

Top Rated Products do_shortcode in php not working when attributes added


When I add this code:

<?php
echo do_shortcode("[top_rated_products orderby="rand" per_page="15"]");
?>

to my php page, it doesn't work, but it works when I use this:

<?php
echo do_shortcode("[top_rated_products ]");
?>

Is there any way to allow for the first code to be used?


Solution

  • You have to wrap the shortcode in single quotes like

    do_shortcode('[top_rated_products orderby="rand" per_page="15"]');