Hello, there is such a thing as meta_query. It is necessary that 2 values ​​fall into value, and not 1 as now.

EXAMPLE:

site.com/?color_value=#9ac317&color_value=#b2004b/ to 'value' => $_GET['color_value'] only #b2004b .

Below is the code for more convenient understanding:

 if(!empty($_GET['color_value'])) $param_1 = array( 'key' => 'select_color', 'value' => $_GET['color_value'], 'compare' => 'LIKE'); $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'orderby' =>'date', 'order' => 'DESC', 'tax_query'=> array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category_id)), 'meta_query' => array($param_1) ); 

    1 answer 1

    When specifying multiple values ​​for a request parameter, you need to specify that it is an array using [] and remove #, because they have a special value in the url:

     site.com/?color_value[]=9ac317&color_value[]=b2004b 

    The code should look like this:

     $category_id = 0; $param_1 = array(); var_dump($_GET['color_value']); echo '<br>'; if(!empty($_GET['color_value'])) { $value = $_GET['color_value']; if (! is_array( $value) ) { $value = array( $value ); } $param_1 = array( 'key' => 'select_color', 'value' => $value, 'compare' => 'LIKE'); } $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'orderby' =>'date', 'order' => 'DESC', 'tax_query'=> array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category_id)), 'meta_query' => $param_1, ); var_dump($args); 

    A working example on my test site: http://test.kagg.eu/wp-content/themes/test/722723.php?color_value[==9ac317&color_value[==2004b

    • not quite good, then through var_dump ($ param_1 = array ($ param_1)) this value is null - Igor PHP
    • what's with var_dump? I didn't understand the comment - KAGG Design
    • I mean that this is not true, since the value is empty - Igor PHP
    • Yes, there were 2 errors, corrected the answer. Now with a working example. - KAGG Design