Skip to content

Commit

Permalink
Search result excerpt documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
joppuyo committed Dec 17, 2018
1 parent 215bf9e commit 4112c47
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ Enable this option to add base forms to search queries entered by users.

Enable this option to split compound words during indexing (and for user queries if the above option is enabled). For example, the word *kerrostaloille* is transformed into tokens *kerrostaloille*, *kerrostalo*, *kerros* and *talo* in the search index.

## Search result excerpts

It's possible to generate Google-style search result excerpts where the keywords are highlighted using `searchwp_finish_base_forms_get_excerpt($post, $options)` function. It takes the following parameters:

* Post you want to create excerpt for
* Array of options
* `length`: length of the excerpt, 300 characters by default
* `query`: current search query, by default it's `get_search_query()`
* `fallback` Anonymous method that generates excerpt to display if the search query is not found in the post content, by default this will use 'excerpt' field and fall back to 'content' field. The text will be truncated according to `length`

This function will automatically check all fields for the search terms that have been configured in SearchWP settings.

## Requirements

* SearchWP 2.5 or later
Expand Down

0 comments on commit 4112c47

Please sign in to comment.