Title: wp_query filtering problem tax_query
Last modified: July 6, 2021

---

# wp_query filtering problem tax_query

 *  Resolved [popcorn294](https://wordpress.org/support/users/popcorn294/)
 * (@popcorn294)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wp_query-filtering-problem-tax_query/)
 * Hi!
    I have a problem with my filtering method. I have a form with multiple filtering
   options. I put these options in my url and I get them with GET. Except that if
   I put “All”, nothing is shown because then my category and my tag are equal to
   nothing.
 *     ```
       <?php
               if($_GET['category'] && !empty($_GET['category']))
               {
                   $category = $_GET['category'];
               }
               if($_GET['tag'] && !empty($_GET['tag']))
               {
                   $tag= $_GET['tag'];
               }
           ?>
       ```
   
 *     ```
       <form action="<?php the_permalink(); ?>" method="get">
   
                   <label>Category:</label>
                   <select name="category">
                       <option value="">ALL</option>
                       <option value="men">Men</option>
                       <option value="women">Women</option>              
                   </select>
                   <label>Tag:</label>
                   <select name="tag">
                       <option value="">ALL</option>
                       <option value="Tag 1">Tag 1</option>
                       <option value="Tag 2">Tag 2</option>                     
                   </select>
                   <button type="submit" name="">Filter</button>
               </form>
       ```
   
 *     ```
       <?php   
                       $args = array(
                           'post_type' => 'product',
                           'posts_per_page' => -1,
                           'product_cat' => $my_parent_category,
                           'tax_query' => array(
                               array(
                                   'taxonomy' => 'product_cat',
                                   'field' => 'slug',
                                   'terms' => $category,
                                   'compare' => 'LIKE',
                               ),
                               array(
                                   'taxonomy' => 'product_tag',
                                   'field' => 'slug',
                                   'terms' => $tag,
                                   'compare' => 'LIKE',
                               ),
                           ),
                       );
       ```
   
 * Is there a way to say; if $category or $tag is null, display all the category
   and tags?
    Thanks `
    -  This topic was modified 4 years, 11 months ago by [popcorn294](https://wordpress.org/support/users/popcorn294/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Gabriel – a11n](https://wordpress.org/support/users/gabrielfuentes/)
 * (@gabrielfuentes)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wp_query-filtering-problem-tax_query/#post-14632458)
 * Hi [@popcorn294](https://wordpress.org/support/users/popcorn294/) 👋
 * This is a fairly complex development topic. I’m going to leave it open for a 
   bit to see if anyone 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.
 * Cheers.
 *  Plugin Support [Gabriel – a11n](https://wordpress.org/support/users/gabrielfuentes/)
 * (@gabrielfuentes)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wp_query-filtering-problem-tax_query/#post-14656473)
 * We’ve not seen any activity on this thread for a while, so I’m marking this thread
   as resolved.
 * Hopefully, you were able to find a solution to your problem! If you have further
   questions, please feel free to open a new topic.
 * Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wp_query filtering problem tax_query’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [Gabriel – a11n](https://wordpress.org/support/users/gabrielfuentes/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/wp_query-filtering-problem-tax_query/#post-14656473)
 * Status: resolved