Showing a banner on the product archive template is a great way to capture the customer’s attention as they browse through your products. This guide shows you how you can show such a banner on a specific category and not on others. This is particularly useful if you’re running a sale only on one product category only or perhaps you need to give customers information about the products on the category as a whole. Simply change the product category slug, the HTML message, and the CSS styling of the message as needed.
/**
* Snippet Name: WooCommerce Show Banner On Specific Product Archive
* Snippet Author: ecommercehints.com
*/
add_action( 'wp_head', 'ecommercehints_specific_product_archive_banner' );
function ecommercehints_specific_product_archive_banner() {
if ( is_product_category( 'accessories' ) ) { // The product category to show the banner ?>
Accessories Sale Ends Tonight!