admin管理员组文章数量:1130349
On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.
On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.
Share Improve this question asked Nov 4, 2013 at 16:23 user41328user41328 191 gold badge1 silver badge2 bronze badges 1- I was researching something else and found the answer! The php file to edit is single-product/meta.php (you can't see this via the Editor from the Dashboard; you need to FTP to get it). I removed: <?php $size = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $size, 'woocommerce' ) . ' ', '.</span>' ); ?> :) – user41328 Commented Nov 4, 2013 at 16:59
2 Answers
Reset to default 4As an alternative to editing the meta template, you can prevent the meta information from being displayed on single product pages at all. This can be handy if you also don't want to display the SKUs. Here is how to do it:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
It goes to your functions.php.
Old question, but I want to point out overriding templates. Nick's answer removes all the meta display. In my case, I only wanted to remove the category and not all the meta information.
Create a copy of single product meta file to yourtheme/woocommerce/single-product/meta.php.
Remove the following line (line 38 on version 3.5):
<?php echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>
This way, you can update WooCommerce without it overwriting your changes.
On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.
On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.
Share Improve this question asked Nov 4, 2013 at 16:23 user41328user41328 191 gold badge1 silver badge2 bronze badges 1- I was researching something else and found the answer! The php file to edit is single-product/meta.php (you can't see this via the Editor from the Dashboard; you need to FTP to get it). I removed: <?php $size = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $size, 'woocommerce' ) . ' ', '.</span>' ); ?> :) – user41328 Commented Nov 4, 2013 at 16:59
2 Answers
Reset to default 4As an alternative to editing the meta template, you can prevent the meta information from being displayed on single product pages at all. This can be handy if you also don't want to display the SKUs. Here is how to do it:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
It goes to your functions.php.
Old question, but I want to point out overriding templates. Nick's answer removes all the meta display. In my case, I only wanted to remove the category and not all the meta information.
Create a copy of single product meta file to yourtheme/woocommerce/single-product/meta.php.
Remove the following line (line 38 on version 3.5):
<?php echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>
This way, you can update WooCommerce without it overwriting your changes.
本文标签: categoriesHow do you remove display of WooCommerce product category on single product page
版权声明:本文标题:categories - How do you remove display of WooCommerce product category on single product page? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749057221a2309537.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论