Related Categories for WooCommerce provides shortcodes so you can output the “Related categories” section wherever you want, and a translation shortcode for multilingual sites. This article lists each shortcode and its attributes.
Available shortcodes #
| Shortcode | Outputs | Registered when |
|---|---|---|
[alg_wc_related_categories_single] |
The single-product related categories section | The Single section is enabled |
[alg_wc_related_categories_loop] |
The archives related categories section | The Archives section is enabled |
[alg_wc_related_categories_translate] |
Text for the active language (WPML/Polylang) | Always |
If you want a shortcode to be the only place the section appears, set Position to Disable on the matching sub-tab so the section is not also hooked into the page automatically.
Attributes for the section shortcodes #
Both [alg_wc_related_categories_single] and [alg_wc_related_categories_loop] accept the same attributes. Each one, when set, overrides the value saved in the plugin settings for that single call:
template_type,template_header,template_footer,template_custom,template_custom_gluelimit,columns,hide_emptyorderby,orderplaceholder_image,image_size,remove_image
[alg_wc_related_categories_single] also accepts product_id to target a specific product, and [alg_wc_related_categories_loop] accepts product_category_id to target a specific category. If you place content between the opening and closing tags, that content is used as the template_custom value.
[alg_wc_related_categories_single limit="6" columns="3" orderby="count" order="DESC"]
[alg_wc_related_categories_loop template_type="custom"]<a href="%category_link%">%category_name%</a>[/alg_wc_related_categories_loop]
For the full list of template placeholders such as %category_name% and %category_link%, see the custom template placeholders reference.
The translation shortcode #
[alg_wc_related_categories_translate] shows different text depending on the active WPML or Polylang language. It is handy inside the Header or Custom templates. There are two ways to use it.
Attribute form, with the text passed as attributes:
[alg_wc_related_categories_translate lang="DE" lang_text="Verwandte Kategorien" not_lang_text="Related categories"]
Wrapping form, with the text between tags. Use lang to show the content only for those languages, or not_lang to show it for every language except those listed:
[alg_wc_related_categories_translate lang="DE"]Verwandte Kategorien[/alg_wc_related_categories_translate][alg_wc_related_categories_translate not_lang="DE"]Related categories[/alg_wc_related_categories_translate]
The lang and not_lang attributes accept a comma-separated list of language codes.
Get more control #
These shortcodes are free. Related Categories for WooCommerce Pro adds hand-picked related categories per product, category, tag and custom taxonomy. See what Pro unlocks.