我一直在尝试找出用于制作自定义搜索表单的正确$ args-array,允许用户按名称,描述和自定义WooCommerce属性搜索产品(现在通过颜色) .
是否可以使用WP_Query或者我是否需要更改内置搜索功能?如果是这样 - 怎么样?
这是我现在一直在尝试的$ args-options:
$args = array(
'posts_per_page' => 20,
'no_found_rows' => true,
'post_type' => array('product'),
'tax_query' => array(
array(
'taxonomy' => 'oct-search',
'field' => 'slug',
'terms' => array($_POST["search_string"]),
),
),
);
1 回答
好的,所以我自己解决了这个问题,使用这段代码: