2017-03-17 7 views
0

私は、単一商品のページコンテンツで出力されるWooCommerceプロダクトIDを取得する必要があります。私は別のものでいくつかの行を表示するテーブルがありますが、このテーブルはすべてのページの製品を表示するのに最適です。しかし、私は誰かが製品をクリックしたときのための単一の製品ページにそれをレンダリングしたい。私は運がない。WooCommerce製品IDを自動的に取得

<?php echo do_shortcode(sprintf('[product_table include="" columns="date,tax:remixer,name:Track Name,tax:bpm,categories:Genre,cf:preview,add-to-cart:Buy,price" shortcodes="true" display_page_length="false" links="none" sort_by="date"]', get_queried_object_id())); ?> 

これは私が持っていたものですが、確かに間違っています。

include="<?php $id = $product->id;(); ?>" 

答えて

0
"' . get_the_ID() . '" 

正しい方法です!

0

Woocommerce Woocommerceのgithubリポジトリがあります。あなたはどのフックを編集すべきかを知ることができます。

同様:

remove_action(‘woocommerce_before_main_content’,‘woocommerce_output_content_wrapper’, 10); 

add_action(‘woocommerce_before_main_content’, ‘my_content_wrapper_start’, 10); 
function my_content_wrapper_start() { 
... 
} 
関連する問題