1 回答

TA貢獻1851條經(jīng)驗 獲得超5個贊
產(chǎn)品元數(shù)據(jù)與模板一起顯示single-product/meta.php,因此您只需要使用專用函數(shù)調(diào)用它即可wc_get_template()。
現(xiàn)在,由于它用于過濾器鉤子,其中使用變量返回顯示,您需要啟用 PHP 緩沖......
那是最終的代碼:
// remove the product meta data
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_filter( 'the_content', 'woocommerce_product_description_and_meta' );
function woocommerce_product_description_and_meta( $content ) {
// Only for single product pages (woocommerce)
if ( is_product() ) {
global $post, $product;
ob_start(); // Start buffering
// The product meta information
wc_get_template( 'single-product/meta.php' );
// Inserting the product meta information display at the end
$content .= ob_get_clean(); // append the buffered display
}
return $content;
}
代碼位于活動子主題(或活動主題)的 functions.php 文件中。測試和工作。
- 1 回答
- 0 關(guān)注
- 203 瀏覽
添加回答
舉報