Skip to content
Advertisement

WooCommerce product additional information shortcode

I am new to WooCommerce and am looking for a solution to display Product attributes on a post page. I’ve made research and some test but nothing seems to work.

Ideally, I would like to use a shortcode taking the Product ID and displaying all his product attributes on my post page. something like [product_page id="99" display_only_attributes ]

Advertisement

Answer

Here is the way to get the product attributes in a custom shortcode where you will define the product ID in as a shortcode argument id.

The function code:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works.

SHORTCODE USAGE (Updated)

  1. with a defined product id:

    JavaScript

    Or in php:

    JavaScript
  2. In an existing product page (when “additional information” product tab is removed for example):

    JavaScript

    Or in php:

    JavaScript

You will get something like this:

enter image description here

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