php - woocommerce 删除所有标签,在页面上显示其内容
问题描述
在尝试了我能找到的每个功能并尝试了 2 天以上的功能后,我一直无法找到一个可行的解决方案。
我正在尝试删除 WooCommerce 描述和评论选项卡,并仅显示描述代替选项卡,并在其下方显示评论选项卡的内容......没有可单击的选项卡。- 我取消设置选项卡并删除,但无法重新添加它们的内容。
我已尝试“删除单个产品选项卡并在 Woocommerce 中添加相关内容”答案代码。
我什至不介意在主题中覆盖 php,但似乎没有任何效果......目标只是让描述显示,并且下面的评论没有标签。任何帮助表示赞赏。
解决方案
要删除选项卡但显示内容,您可以使用以下内容。
// Remove
function remove_product_tabs( $tabs ) {
unset( $tabs['description'] );
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'remove_product_tabs', 98, 1 );
// Tabs callback function after single content.
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_description_tab' );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_additional_information_tab' );
add_action( 'woocommerce_after_single_product_summary', 'comments_template' );
为避免折叠,请编辑以下模板
https://github.com/woocommerce/woocommerce/blob/master/templates/single-product/tabs/description.php
- 此模板可以通过将其复制到
yourtheme/woocommerce/single-product/tabs/description.php
.
代替
<?php if ( $heading ) : ?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php the_content(); ?>
和
<div style="clear:both;">
<?php if ( $heading ) : ?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php the_content(); ?>
</div>
进一步的定制是 html 和/或 css 修改的问题,具体取决于您的主题
推荐阅读
- android - Canvas drawText(字体)导入Times字体?
- node.js - EACCES:权限被拒绝在 Mac 上使用 npm 安装 NWjs
- vba - 判断树节点是否存在
- c - 如何在 macOS 上使用 GDB 调试器?
- angular - 如何使用 Angular 从 twitter api 读取属性
- keras - 如何访问包含预训练模型的自定义模型的即时激活?
- python - 如何从python中的不同文件调用函数?
- google-apps-script - 在 Google 幻灯片上自动更新电子表格范围
- python - 在 Python 中运行完成后,无法让更大的代码循环
- python - 如何使用 altair 在 hconcat 图表中显示两个不同的图例