Hide Prices on the Shop and Category Pages

Hide Prices on the Shop & Category Pages in WooCommerce

Table of Contents

Hide Price on Shop & Category

To hide prices on the shop and category pages in WooCommerce, you can use the following function:

				
					function hide_prices_shop_pages() {
  if ( ! is_admin() ) {
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
  }
}
add_action( 'init', 'hide_prices_shop_pages' );

				
			

This function removes the action that displays the price for each product on the shop and category pages. You can add this function to your theme’s functions.php file or you can use a plugin like “Code Snippets” to add it to your site.

Keep in mind that this function will hide the prices for all products on the shop and category pages.

Hide Price on Category only

If you only want to hide the prices for certain products or categories, you can use conditional statements to check for these conditions before removing the action.

For example, to hide the prices for a specific product category, you can use the is_product_category() function:

				
					function hide_prices_shop_pages() {
  if ( ! is_admin() && is_product_category( 'clothing' ) ) {
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
  }
}
add_action( 'init', 'hide_prices_shop_pages' );

				
			

This will hide the prices for all products in the “clothing” category on the shop and category pages.

END

Leave a Comment

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Scroll to Top