Skip to content

Commit

Permalink
Update search.php
Browse files Browse the repository at this point in the history
Add switch for term_id and slug depending on input.
  • Loading branch information
pkevan authored May 14, 2024
1 parent 3d5f9d8 commit 45cff95
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@ function modify_es_query_args( $es_query_args, $wp_query ) {
if ( ! in_array( $taxonomy, array( 'wporg-pattern-category', 'wporg-pattern-keyword' ) ) ) {
continue;
}

$filter['bool']['must'][] = [
'term' => [ "$taxonomy.slug" => $term['terms'] ],
];
if ( is_string( $term['terms'] ) ) {
$filter['bool']['must'][] = [
'term' => [ "taxonomy.$taxonomy.slug" => $term['terms'] ],
];
} else if ( is_int( $term['terms'] ) ) {
$filter['bool']['must'][] = [
'term' => [ "taxonomy.$taxonomy.term_id" => $term['terms'] ],
];
}
}
}

Expand Down

0 comments on commit 45cff95

Please sign in to comment.