- {facets.map(({ name, label, type }, index) => (
-
+ {facets.map((facet, index) => (
+
))}
diff --git a/assets/js/instant-results/components/results/result.js b/assets/js/instant-results/components/results/result.js
index 96ec38cfb4..ebe9188ac8 100644
--- a/assets/js/instant-results/components/results/result.js
+++ b/assets/js/instant-results/components/results/result.js
@@ -32,7 +32,7 @@ export default ({ hit }) => {
},
} = hit;
- const postTypeLabel = postTypeLabels?.[resultPostType];
+ const postTypeLabel = postTypeLabels[resultPostType]?.singular;
return (
singular_name;
+ $post_type_labels = get_post_type_labels( $post_type_object );
- $labels[ $post_type ] = $post_type_label;
+ $labels[ $post_type ] = array(
+ 'plural' => $post_type_labels->name,
+ 'singular' => $post_type_labels->singular_name,
+ );
}
return $labels;
@@ -643,12 +646,13 @@ public function get_facets() {
* Post type facet.
*/
$facets['post_type'] = array(
- 'type' => 'post_type',
- 'labels' => array(
+ 'type' => 'post_type',
+ 'post_types' => [],
+ 'labels' => array(
'admin' => __( 'Post type', 'elasticpress' ),
'frontend' => __( 'Type', 'elasticpress' ),
),
- 'aggs' => array(
+ 'aggs' => array(
'post_types' => array(
'terms' => array(
'field' => 'post_type.raw',
@@ -674,12 +678,13 @@ public function get_facets() {
);
$facets[ $slug ] = array(
- 'type' => 'taxonomy',
- 'labels' => array(
+ 'type' => 'taxonomy',
+ 'post_types' => $taxonomy->object_type,
+ 'labels' => array(
'admin' => $admin_label,
'frontend' => $labels->singular_name,
),
- 'aggs' => array(
+ 'aggs' => array(
'taxonomy_terms' => array(
'terms' => array(
'field' => 'terms.' . $slug . '.facet',
@@ -695,12 +700,13 @@ public function get_facets() {
*/
if ( $this->is_woocommerce ) {
$facets['price_range'] = array(
- 'type' => 'price_range',
- 'labels' => array(
+ 'type' => 'price_range',
+ 'post_types' => [ 'product' ],
+ 'labels' => array(
'admin' => __( 'Price range', 'elasticpress' ),
'frontend' => __( 'Price', 'elasticpress' ),
),
- 'aggs' => array(
+ 'aggs' => array(
'max_price' => array(
'max' => array(
'field' => 'meta._price.double',
@@ -734,9 +740,10 @@ public function get_facets_for_frontend() {
$facet = $available_facets[ $key ];
$facets[] = array(
- 'name' => $key,
- 'label' => $facet['labels']['frontend'],
- 'type' => $facet['type'],
+ 'name' => $key,
+ 'label' => $facet['labels']['frontend'],
+ 'type' => $facet['type'],
+ 'postTypes' => $facet['post_types'],
);
}
}