Title: Attribute numeric range filter
Last modified: April 6, 2022

---

# Attribute numeric range filter

 *  Resolved [umbzwp](https://wordpress.org/support/users/umbzwp/)
 * (@umbzwp)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/attribute-numeric-range-filter/)
 * Hi,
 * I am trying to filter a Woocommerce attribute by numeric range.
    Woocommerce 
   attributes are text based, but there are some plugins around that offer attribute
   filter by range. Any idea how to setup a non-numeric range?
 *     ```
           <?php 
       	if ( woocommerce_product_loop() ) { 
   
       		$prodLenghtMin = intval( $prodLenghtMin );
       		$prodLenghtMax = intval( $prodLenghtMax );
       		$range = range($prodLenghtMin, $prodLenghtMax);
   
       		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
   
       		$args = array(
       		'post_type'      => 'product',
       		'posts_per_page' => 10,
       		'orderby'=>'title',
       		'order' => 'ASC', 
       		'paged' => $paged
       		);
   
       		if ( $prodColor || $prodBrand || $prodLenghtMin ||  $prodLenghtMax ) {
       		  $args['tax_query'] = array();
       		  if ( $prodColor ) {
       		    $args['tax_query'][] = array(
       		      'taxonomy' => 'pa_color',
       		      'field' => 'slug',
       		      'terms' => $prodColor
       		    );
       		  }
   
       		  if ( $prodBrand ) {
       		   $args['tax_query'][] = array(
       		     'taxonomy' => 'pa_width',
       		     'field' => 'slug',
       		     'terms' => $prodBrand
       		    );
       		  }
                 // this doesn't work:
       		  if ( $prodLenghtMin ||  $prodlenghtMax ) {
       		   $args['tax_query'][] = array(
       		     'taxonomy' => 'pa_lenght',
       		     'field' => 'slug',
       		     'type' => 'NUMERIC',
       		     'terms' => $range
       		    );
       		  } // end this doesn't work
   
       		}
   
               $loop = new WP_Query( $args );
       		   while ( $loop->have_posts() ) : $loop->the_post();
       			  global $product;
   
                    // [...] 
                 endwhile; 
              wp_reset_postdata(); 
   
            }?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Support [Paulo P – a11n](https://wordpress.org/support/users/paulostp/)
 * (@paulostp)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/attribute-numeric-range-filter/#post-15532035)
 * Hello,
 * Thanks for reaching out!
 * This is a fairly complex development topic – code customization is outside our
   scope of support.
 * I’m going to leave it open for a bit to see if anyone from the community is able
   to chime in to help you out.
 * I can also recommend [the WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
   for resources on developing for WooCommerce.
 * You can also visit the [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
   We’re lucky to have a great community of open-source developers for WooCommerce,
   and many of our developers hang out there, as well.
 * Best,

Viewing 1 replies (of 1 total)

The topic ‘Attribute numeric range filter’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Paulo P – a11n](https://wordpress.org/support/users/paulostp/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/attribute-numeric-range-filter/#post-15532035)
 * Status: resolved