WooCommerce taxonomies provide a compact vocabulary for product retrieval. Categories, tags, attributes, brands, collections, and custom classification systems can help a retrieval-augmented generation pipeline identify relevant products and explain why they match a customer’s request.
Which WooCommerce taxonomies are useful for retrieval?
A product’s taxonomy terms should be treated as structured metadata rather than ordinary prose. Common sources include:
- Product categories: The primary merchandising hierarchy, such as Running Shoes, Trail Shoes, or Accessories.
- Product tags: Flexible descriptors such as waterproof, vegan, or limited edition.
- Global attributes: WooCommerce attributes such as size, color, material, and fit. These are commonly represented by taxonomies such as
pa_colorandpa_material. - Brands and collections: Custom taxonomies frequently added by agencies or extensions.
- Product type and visibility: Operational taxonomies such as
product_typeandproduct_visibility, which can help exclude irrelevant or unavailable products.
Taxonomy names and term names should not be assumed to have the same meaning across stores. One merchant may use formal as a tag, while another may use a category called Business Shoes. The ingestion process should preserve the taxonomy name, term ID, slug, and display label.
Represent terms as filterable metadata
A useful product document contains both natural-language content for semantic search and normalized taxonomy metadata for exact filtering. For example:
{"product_id": "4821", "title": "Summit Waterproof Trail Shoe", "taxonomies": {"product_cat": [{"id": 37, "slug": "trail-shoes", "name": "Trail Shoes"}], "product_tag": [{"id": 91, "slug": "waterproof", "name": "Waterproof"}], "pa_material": [{"id": 14, "slug": "synthetic", "name": "Synthetic"}]}, "search_text": "Summit Waterproof Trail Shoe. Trail Shoes. Waterproof. Synthetic."}
The taxonomies object supports exact filters, auditability, and rule-based routing. The search_text field gives an embedding model enough context to connect a query such as “waterproof shoes for hiking” with the product even when the customer does not use the exact catalog wording.
Use taxonomy terms in the retrieval pipeline
A practical pipeline usually performs four steps:
- Extract: Read terms from the WooCommerce product and its assigned taxonomies.
- Normalize: Store stable slugs and IDs, while retaining the human-readable names for display and generation.
- Index: Add taxonomy text to the embedding input and store each taxonomy as filterable metadata in the vector database or search index.
- Retrieve and validate: Apply exact filters where the user expresses a clear constraint, then use semantic similarity to rank the remaining products.
For example, a request for “black waterproof trail shoes under $150” should not rely on vector similarity alone. The retrieval layer should interpret black, waterproof, and trail shoes as candidate taxonomy or attribute filters, apply the price constraint against current product data, and use semantic ranking only to order the valid results.
Build taxonomy context for generation
Retrieved terms can be supplied to the language model as concise, labeled evidence. Labels prevent the model from confusing a category with a marketing claim:
Product: Summit Waterproof Trail Shoe
Category: Trail Shoes
Tags: Waterproof
Material: Synthetic
Color: Black
Availability: In stock
Price: 129.00 USD
This structure is preferable to inserting an unlabelled list such as “Trail Shoes, Waterproof, Synthetic, Black.” It allows the generation step to distinguish classification data from descriptive copy and makes it easier to enforce response rules such as “mention only attributes present in the retrieved record.”
Retrieve parent and child categories deliberately
WooCommerce categories are hierarchical. A product assigned to Trail Shoes may also be conceptually related to its parent category, Shoes, but the WordPress term relationship does not always mean that every ancestor is explicitly assigned to the product in the way an application expects.
During indexing, agencies should decide whether to store:
- The directly assigned terms only.
- The complete ancestor path, such as
Shoes > Trail Shoes. - Separate fields for the leaf term, ancestor terms, and display path.
Storing the complete path improves context and breadcrumbs. Filtering should generally use the canonical term IDs or slugs rather than matching the rendered path as free text.
Do not treat tags as verified product facts
Tags are often editorial and inconsistently maintained. A tag named eco might represent a certified material in one store and a campaign theme in another. Before using a tag as evidence in a generated answer, establish a taxonomy policy:
- Define which taxonomies represent factual specifications.
- Define which taxonomies represent merchandising or campaign labels.
- Map aliases and spelling variants to canonical terms.
- Record term changes and reindex affected products.
- Exclude internal terms, hidden terms, and administrative labels from customer-facing context.
When a term is promotional rather than factual, the generation prompt should describe it as a collection or merchandising label instead of making a stronger claim. For regulated attributes such as medical suitability, sustainability certifications, or safety ratings, use a verified product field or a trusted document source rather than an ungoverned tag.
Extract taxonomy data through WordPress
For a WordPress REST API integration, product records can be read from the WooCommerce product endpoints, while custom taxonomy terms may require the relevant taxonomy REST route and permission configuration. A response mapper should preserve IDs and slugs instead of indexing only rendered names.
function taxonomy_context( $product ) {
$context = array();
$taxonomies = array( 'product_cat', 'product_tag', 'pa_color', 'pa_material' );
foreach ( $taxonomies as $taxonomy ) {
$terms = get_the_terms( $product->get_id(), $taxonomy );
if ( is_wp_error( $terms ) || empty( $terms ) ) {
continue;
}
$context[ $taxonomy ] = array_map(
static function ( $term ) {
return array(
'id' => (int) $term->term_id,
'slug' => $term->slug,
'name' => $term->name,
);
},
$terms
);
}
return $context;
}
The exact extraction method depends on the store’s authentication model, custom taxonomies, and extensions. Agencies should also account for variable products: taxonomy assignments may live on the parent product, while important values such as variation color or size may be stored on individual variations.
Handle taxonomy changes and stale embeddings
Taxonomy edits are content changes. Renaming a term, moving a category, removing a tag, or changing a product assignment can make both metadata filters and embedded text stale.
Use a synchronization process that records the product ID, taxonomy version or last-modified timestamp, and index status. Reindex a product when its term relationships change. If term definitions are included in many documents, maintain a term alias map or regenerate affected documents when a canonical label changes.
At query time, apply availability, catalog visibility, stock, price, and permission rules from current WooCommerce data. Taxonomy context can improve relevance, but it should not override live commerce constraints.