WooCommerce 产品 - 显示产品对象的 post_content 值
WooCommerce product - Displaying post_content value of product object
当我使用时:
print_r($product);
它returns以下内容:
WC_Product_Simple
Object
( [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
.....
如何回显 [post_content]
的值?
我正在使用带有 WooCommerce 插件的 WordPress。
谢谢。
如您所见,您的 $product
是一个包含 post
对象(而不是数组)。所以你可以尝试其中之一:
$product_content = $product->post->post_content;
echo $product_content;
// or directly
// echo $product->post->post_content;
或者这个也应该有效:
$_product = $product->post;
echo $_product->post_content;
当我使用时:
print_r($product);
它returns以下内容:
WC_Product_Simple
Object
( [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
.....
如何回显 [post_content]
的值?
我正在使用带有 WooCommerce 插件的 WordPress。
谢谢。
如您所见,您的 $product
是一个包含 post
对象(而不是数组)。所以你可以尝试其中之一:
$product_content = $product->post->post_content;
echo $product_content;
// or directly
// echo $product->post->post_content;
或者这个也应该有效:
$_product = $product->post;
echo $_product->post_content;