Skip to content
Advertisement

Display related products using a shortcode on WooCommerce My account Dashboard

I’m trying to display related products in My account Dashboard page. I followed this WooCommerce Shortcodes documentation.

I tried to use the following code:

JavaScript

This does not display the related products. But when I try to display products in specific category like following, it works:

JavaScript

Kindly any help to resolve this?

Advertisement

Answer

Note that related products shortcode need to be used on single product pages, as related products are always linked to a product, that’s why [related_products limit="3"] shortcode doesn’t work on My account dashboard.

Now to target my account dashboard, replace in your function this code lines:

JavaScript

by this unique code line:

JavaScript

It’s much better. See WooCommerce Conditional Tags

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement