• I have an attribute for width that I would like to be able to filter via range… so I have a product with a width of 4.25 and when I do a search for any product with a width between 3 and 6 that product should display, but I’m not sure how to work with taxonomies… I’ve tried using this

    $query_args['tax_query'][] = array(
                    'taxonomy' => 'pa_width',
                    'terms' => array(3, 6),
                    'field' => 'slug',
                    'operator' => 'IN'
            );

    But I don’t get any results. Is there a way to do this?

Viewing 1 replies (of 1 total)
  • This does not really answer your question, but if possible, the search would be much easier if you can use a Custom Field to hold the width. The meta_query has a comparison operator of ‘BETWEEN’ that should work.

    The only way I can think of to do the search on a taxonomy would be to use filters to join the wp_term_relationships, wp_term_taxonomy, and wp_terms tables and add a ‘where’ clause to select the matching items. Much easier to use the Custom Field approach, if at all possible.

Viewing 1 replies (of 1 total)

The topic ‘Attribute Range Filtering Help Needed’ is closed to new replies.