wordpress 在产品页面上隐藏产品标题和类别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17827595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide product title and categories on product page
提问by user1833760
How could I hide product title and categories on a single product page in WooCommerce:
如何在 WooCommerce 的单个产品页面上隐藏产品标题和类别:
I know I can edit/comment the source code but then I have to manually do it after each update. Is there a function I can add to theme functions.php that can remove product title and categories from single product page?
我知道我可以编辑/评论源代码,但每次更新后我都必须手动进行。有没有我可以添加到主题functions.php的功能,可以从单个产品页面中删除产品标题和类别?
回答by prms
For compatibility with future updates of your theme and plugins, I've found a better way to do this is through WooCommerce hooks. To remove both the title and the meta-data items from your Single Product Page, you should put the following two lines in your theme's main functions.php:
为了与您的主题和插件的未来更新兼容,我发现一个更好的方法是通过WooCommerce hooks。要从单个产品页面中删除标题和元数据项,您应该在主题的 main functions.php 中添加以下两行:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
You can find more info about changing, or re-ordering your Product Page Contents in this post.
您可以在这篇文章中找到有关更改或重新订购产品页面内容的更多信息。
回答by Balram Singh
Simplest Solution is go to woocommerce plugin /templates/single-product/title.php and remove content of this file.
最简单的解决方案是转到 woocommerce 插件 /templates/single-product/title.php 并删除此文件的内容。
Same process can be done by removing content of meta file in same directory.
可以通过删除同一目录中元文件的内容来完成相同的过程。