WooCommerce: Display Category Name

WooCommerce: Display Category Name

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

WooCommerce: Display Category Name

When building a product archive page in WooCommerce, you often encounter a specific header behavior that can clutter your layout. The default implementation usually relies on wp_title() or similar functions to generate the heading. However, this approach inherits the full breadcrumb trail from WordPress, resulting in output like » Product Categories » Bracelets instead of the clean, singular title Bracelets you likely want for your design system.

The core issue here is that wp_title() is designed to return the hierarchical path within the site structure, not just the current page slug or term name. It concatenates the parent term (usually "Product Categories") with the child term using WordPress's standard separator. To achieve a custom display where only the specific category name appears as the H1 tag, you need to bypass the global title generation and explicitly query the current term object within your template logic.

The most robust solution involves modifying your archive-product.php file or creating a child theme override to hook directly into the context of the archive. Instead of relying on dynamic functions that pull from the global navigation stack, you should retrieve the specific term associated with the current product query.

You can achieve this by accessing the queried object within your template file. If you are using the default WooCommerce structure, the archive page relies on a specific variable to hold the current term data. However, simply printing get_the_terms() might return an array that requires iteration. A cleaner approach is to utilize the global $wp_query or check if a custom query was used for the archive.

Here is a practical implementation strategy using the woocommerce_archive_page_header_title filter or by directly manipulating the title in your template:

// In your theme's functions.php or within the specific template file
add_filter( 'single_product_show_summary', '__return_false' ); // Not relevant here, but good to remember filters exist.

// To override the header specifically for product archives
function custom_archive_header_title() {
    global $wp_query;
    
    // Check if we are on a product archive page
    if ( is_product_category() || is_shop ) {
        // Get the current term object based on the taxonomy
        $current_term_id = get_queried_object_id(); 
        $taxonomy_name = 'product_cat'; // Default WooCommerce taxonomy
        
        // Retrieve the term name directly
        $term_name = get_term( $current_term_id, $taxonomy_name );
        
        if ( ! is_wp_error( $term_name ) && isset( $term_name->name ) ) {
            echo '<h1 class="archive-title">' . esc_html( $term_name->name ) . '</h1>';
            // Optionally return early to prevent wp_title() from running again
            // return; 
        }
    }
}
add_action( 'woocommerce_before_main_content', 'custom_archive_header_title' );

This code snippet explicitly fetches the term name using get_term() and outputs it within an H1 tag. By placing this action early in the load order—specifically before wp_title() runs if you are outputting it directly via PHP, or simply replacing the standard header logic—you ensure no breadcrumb artifacts appear.

A critical trade-off to consider is where you place this logic. Modifying core files like archive-product.php directly is generally discouraged as updates will overwrite your changes. The preferred method is creating a child theme and placing the modified template there, or using the action hooks provided by WooCommerce to inject the header content without touching the file structure permanently.

Another consideration involves SEO and accessibility. While stripping the parent term "Product Categories" makes the title cleaner for users, search engines sometimes rely on hierarchical context. However, since modern crawlers understand site structures well, a clear, specific H1 like Bracelets is actually beneficial for keyword relevance. It tells the crawler exactly which subset of products you are targeting, rather than a generic category list.

If you are using a page builder or a theme that heavily relies on conditional logic, ensure that your custom hook doesn't conflict with existing header templates. Always test your changes in a staging environment first. The goal is to replace the noisy default output with a semantic, single-term title that matches your intended design while maintaining the underlying data integrity of the archive page.

Our network