asp_result_groups
Search results when the results grouping feature is enabled
Accessing the results groups when the results grouping is enabled.
1
apply_filters('asp_result_groups', array $groups, int $id, array $args);
Copied!

Parameters

  • $groups(array) - Array containing the results grouped
  • $id(int) - Search instance ID
  • $args (array) - Search arguments

Usage

1
add_filter( 'asp_result_groups', 'asp_result_groups_modify', 10, 1 );
2
function asp_result_groups_modify( $groups) {
3
foreach ($groups as $slug=>&$group) {
4
/**
5
* $slug (string) = 'group_slug',
6
* $group (array) [
7
* 'title' => 'Group header title',
8
* 'items' => array(...) // The actual results
9
* ]
10
**/
11
if ( $group['title'] == 'Group title' ) {
12
// Change the group title
13
$group['title'] == 'Modified group title';
14
15
// Unset items from group where post ID is 123
16
foreach ( $group['items'] as $k=>&$r ) {
17
if ( $r->id == 123 ) {
18
unset($group['items'][$k]);
19
}
20
}
21
}
22
}
23
24
return $groups ;
25
}
Copied!
Last modified 3mo ago
Copy link