2017-03-17 155 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有一個gocomub倉庫Woocommerce,你可以看到你應該編輯哪個鉤子。

像:

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() { 
... 
}