Maankoning Maankoning - 1 year ago 159
PHP Question

WooCommerce product - Displaying post_content value of product object

When I use


It returns the following:

( [id] => 156
[post] => WP_Post Object
( [ID] => 156
[post_author] => 1
[post_date] => 2016-07-01 08:59:05
[post_date_gmt] => 2016-07-01 06:59:05
[post_content] => single product with picture


How do I echo out the value for

I am using WordPress with WooCommerce plugin.


Answer Source

As you can see your $product is an object that contains a post object (and not arrays). So you could try one of this:

$product_content = $product->post->post_content;
echo $product_content;
// or directly
// echo $product->post->post_content;

or this one should work too:

$_product = $product->post;
echo $_product->post_content;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download