Indexing product_cat
-
I’ve been struggling to index the taxonomy type ‘product_cat’. I’ve selected it within the indexing settings, turned on indexing for taxonomy terms, rebuilt the index multiple times, increased the weight for ‘product_cat’, and tried several code snippets I found on the Relevanssi site included below.
add_filter( 'relevanssi_content_to_index', 'rlv_parent_categories', 10, 2 ); function rlv_parent_categories( $content, $post ) { $categories = get_the_terms( $post->ID, 'product_cat' ); if ( is_array( $categories ) ) { foreach ( $categories as $category ) { if ( ! empty( $category->parent ) ) { $parent = get_term( $category->parent, 'product_cat' ); $content .= $parent->name; } } } return $content; }
add_filter( 'relevanssi_modify_wp_query', 'rlv_include_product_cat' ); function rlv_include_product_cat( $query ) { if ( isset( $query->query_vars['product_cat'] ) ) { $query->query_vars['tax_query'][] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $query->query_vars['product_cat'], 'include_children' => false, ); } return $query; }
I’m out of ideas at this point. Could someone give me some advice?
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Indexing product_cat’ is closed to new replies.