Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it’s on-topic for WordPress Development Stack Exchange.
Closed 6 years ago .
I’m trying to remove the word Category from the product page.
As far as I know the code that displays that is woocommerce_template_single_meta located into content-single-product.php file:
<?php
/**
* woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
I would like to know how I can modify and customize this hook, so I would be able to place it where I want and use my own styles.
This will definitely remove the word “category”. Add this code in functions.php.As you already know woocommerce_template_single_meta
is the hook responsible for meta information of the single-product.
File is present in /woocommerce/templates/single-product/meta.php
. Either you can use the following code to edit the HTML of meta.php or you can copy the file meta.php to themes/your-theme/woocommerce/single-product/meta.php
. Then edit the meta.php as you want it to be.
<?php
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta_remove_category', 40 );
function woocommerce_template_single_meta_remove_category(){
global $post, $product;
$cat_count = ( !empty( $cats ) && ! is_wp_error( $cats ) ) ?
count($cats) : 0;
$tag_count = ( !empty( $tags ) && ! is_wp_error( $tags ) ) ? count($tags) : 0;
?>
<div class="product_meta">
<?php do_action( 'woocommerce_product_meta_start' ); ?>
<?php if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?>
<span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : __( 'N/A', 'woocommerce' ); ?></span>.</span>
<?php endif; ?>
<?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( '', '', $cat_count, 'woocommerce' ) . ' ', '.</span>' ); ?>
<?php echo $product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' ); ?>
<?php do_action( 'woocommerce_product_meta_end' ); ?>
</div>
<?php
}