alleyinteractive / alleyinteractive/searchpress

Facet query var helper doesn't support 3+ terms

Đang mở
#82 0 bình luận 0 reaction 1 người được giao Được @mboynes nhận Xem trên GitHub
Faceting
Ngôn ngữ chính
PHP
Star
85
Fork
10
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Basic example

```php
add_filter( 'sp_search_wp_query_args', function( $wp_args ) {
$wp_args['facets'] = [
'Category' => [
'type' => 'taxonomy',
'taxonomy' => 'category',
'count' => 10,
],
];

return $wp_args;
} );
```

When outputting the facets, e.g. as links, the `query_vars` entry in the processed facet data contains the query vars needed to generate a link to filter the results:

```php
$facet_data = SP_Integration()->search_obj->get_facet_data();
if ( ! empty( $facet_data['Category']['items'] ) ) :
foreach ( $facet_data['Category']['items'] as $cat ) :
?>






  • tax_query->queries`. It's important to note that union queries (`?taxonomy=term1+term2`) will add multiple arrays to `$GLOBALS['wp_query']->tax_query->queries`, whereas intersection queries (`?taxonomy=term1,term2`) will add multiple terms a single array entry. Here's a `var_export()` dump illustrating this:

    ```
    ?s=markup&category_name=antiquarianism,aciform
    $GLOBALS['wp_query']->tax_query->queries
    array (
    0 =>
    array (
    'taxonomy' => 'category',
    'terms' =>
    array (
    0 => 'antiquarianism',
    1 => 'aciform',
    ),
    'field' => 'slug',
    'operator' => 'IN',
    'include_children' => true,
    ),
    )

    ‌‌?s=markup&category_name=antiquarianism+aciform
    $GLOBALS['wp_query']->tax_query->queries
    array (
    0 =>
    array (
    'taxonomy' => 'category',
    'terms' =>
    array (
    0 => 'antiquarianism',
    ),
    'field' => 'slug',
    'operator' => 'IN',
    'include_children' => true,
    ),
    1 =>
    array (
    'taxonomy' => 'category',
    'terms' =>
    array (
    0 => 'aciform',
    ),
    'field' => 'slug',
    'operator' => 'IN',
    'include_children' => true,
    ),
    )
    ```

    In addition, it looks like we're not fully accounting for union queries when building the query var arrays in the facet data. [Relevant code in core](https://github.com/WordPress/WordPress/blob/564d6a0c909af6d09bd91b7725587bf715cc8b1b/wp-includes/class-wp-query.php#L1103-L1114) to mimic for consistency.

    Hướng dẫn đóng góp

    Mở hướng dẫn đóng góp

    Đánh giá

    Issue này chưa được đánh giá.

    Nhận issue mới trong hộp thư của bạn

    Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.