How can I create a shortcode that shows a list of categories on the single product page?

Question

This may seem simple but I want to create a shortcode called [woo_prod_categories] that will simply display a list of the categories of a specific product on the single product page (each linked to their category page).

I did this for the SKU:

function display_woo_cat() {

global $product;
return $product->get_sku();


}
add_shortcode( 'woo_prod_category', 'display_woo_cat' );

I can tried the shortcodes I found in the WooCommerce documentation but they just show all the categories. I know there are ways to do this via standard single product pages turning on options in the WooCommerce settings. I am trying to make a custom single product page. I am using elementor and I know there are elements that can do this. I just want a list of categories that are linked back to the category page that are produced by a shortcode.

I want to put this shortcode in a table so it matches the meta data like attributes, dimensions, etc.

Does anyone have any idea how I can do this quick and easy?

0
Inventive Web Design 1 week 2023-05-22T23:02:16-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse