Viewing 3 replies - 1 through 3 (of 3 total)
  • I tried this and like you, found it didn’t work. I enabled debug mode to be able to see any error messages. An error message showed that it failed because there is no product in the page. If there is no product, there can’t be anything related to it. Seems reasonable.

    I tried it on a product page and it worked fine.

    Thread Starter pinkhare

    (@pinkhare)

    Thanks for the reply!
    I already had tried to add a [product_page] and a [related_products] shortcodes on a same page, but nothing was displayed. But the strange thing is that it works when I added it with a [add_to_cart_url] shortcode, but not with a [product_page].

    I tried [product id=”99″] and that didn’t work either. [related_products] is expecting a variable called “$product” to exist in the page. Looking at class-wc-shortcodes.php, the variable “$product” is not used except for the add-to-cart_url shortcode.

    So maybe you could use the add_to_cart_url shortcode to create the “$product” variable, but if you don’t want it showing, just hide it with some custom css.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[related_products] shortcode displays nothing’ is closed to new replies.