Lia*_*nne 4 php wordpress product woocommerce hook-woocommerce
我已使用此挂钩的第一个选项(其他选项不起作用)->所有产品的 Woocommerce 产品默认描述
这就是它的样子(红色标记的文字是标准描述)
但是,我希望文本出现在产品描述之后。红色箭头所在的位置是标准文本。所以上面的“in winkelmand”(意思是“添加到购物袋”)
我怎样才能实现这个目标?
这可以通过以下代码(已注释)来完成:
// 1. Remove the description product tab
add_filter( 'woocommerce_product_tabs', 'remove_descrip_product_tab', 98 );
function remove_descrip_product_tab( $tabs ) {
// Remove the description tab
unset( $tabs['description'] );
return $tabs;
}
// 2. Add the product description after the product short description
add_action( 'woocommerce_single_product_summary', 'my_custom_action', 25 );
function my_custom_action() {
global $post;
// Product description output
echo '<div class="product-post-content">' . get_the_content() . '</div>';
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(或活动主题)的 function.php 文件中。经过测试并有效。
小智 5
那个也不适合我,所以我继续寻找并找到了这个,效果非常好
// Move Description to Under Price WooCommerce
function woocommerce_template_product_description() {wc_get_template( 'single-product/tabs/description.php' );}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 20 );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9014 次 |
| 最近记录: |