Manipulate Search
-
Hello.
We use advanced custom fields and we have 2 fields inside every post.
min_number and max_number custom fields.
So for example. Post-1 has min_number:100 and max_number:150, Post-2 has min_number:200 and max_number:250 as custom fields.
We index these fields with relevanssi but we want to somehow hook to the search engine and when the user searches for 130, Post-1 will return, if he searches 238, Post-2 will return.
This is by checking to see if the search number value is between min_number and max_number range.
We have a draft of the custom php function that we want to use but we do not know what hook to use it with relevanssi.
The function will be something like
function getPostbyRange($inputNumber, $postsArray) { $result = []; foreach ($postsArray as $post) { $min_num = $acf['min_number']; $max_num = $acf['max_number']; if ($inputNumber >= $min_num && $inputNumber <= $max_num) { $result[] = $post; } } return $result; }
Thank you.
- The topic ‘Manipulate Search’ is closed to new replies.