2016-07-28 14 views
1

のPOST_CONTENT値を表示:WooCommerce製品 - 私が使用した場合、製品のオブジェクト

print_r($product); 

それは次の値を返します。

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を使用しています。

ありがとうございました。

答えて

1

あなた$productpostオブジェクト(およびない配列)を含むオブジェクトです見ることができるように。だから、これの1試みることができる:

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

するか、この1はあまりにも動作するはずです:

$_product = $product->post; 
echo $_product->post_content; 
+0

凡例です!私は製品を '[post]' ['post_content'] – Maankoning

+0

done :)を試しました私は今6年前にphpをするために使用され、私はかなり前にオブジェクトを使用することはありませんでした – Maankoning

関連する問題