-4

I'm looking for simple solution how to convert URL query like this:

?orderby=date-desc&query_type_color=or&filter_color=white,black&query_type_material=or&filter_material=iron&min_price=120&max_price=1190

into product loop query for WooCommerce. I prefer to use WP_Query or wc_get_products.

Please notice that query must contains all possible woocommerce product filter options like, order, orderby, taxonomy, attributes, min/max price, ...

I don't want to use any plugin.

Thanks

quarky
  • 710
  • 2
  • 13
  • 36

1 Answers1

0

You can do it in the following way.

  add_query_arg( array(
        'orderby' => 'date-desc',
        'query_type_color' => 'or',
        'filter_color' => 'white'
        ........
        .........
    ), 'http://example.com');
Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
Mainul Hasan
  • 691
  • 3
  • 12
  • Thank for response, but how can I use your solution into WP_Query? I don't need to build query, instead I need to pass args to WP_Query for loop through the products. – quarky Oct 05 '21 at 06:13