Suggested answers
The Suggested answers add-on shows articles that may answer a question while visitors type it in your form. If one does, they don’t need to write, and fewer questions reach your inbox.
Articles come from this site (posts, pages, a docs post type, any public kind) or from another WordPress site, such as your docs on their own domain. They show after a short pause in typing: where the form’s Suggested answers field is, or, without one, under the last field it looks in.
Place them yourself: in the form editor, click More → Suggested answers and drag its chip where the articles should show, such as above the message or next to the send button. It takes no room until there are articles to show, and it’s never sent.
Set it up
- Open a form, then its Suggested answers tab.
- Under Look for answers to what they type in, tick the fields, usually the subject and the message.
- Pick Articles from: This site, with the kinds of posts, or Another WordPress site, with its address.
The form’s Suggested answers tab
| Setting | What it does |
|---|---|
| Look for answers to what they type in | The text fields it reads. Nothing ticked: no suggestions on this form. |
| Articles from | This site, or another WordPress site with its REST API open (it is by default). |
| Of these kinds | This site’s public post types to search. Posts and pages at first. |
| Address of that site | The other site’s home page, such as https://docs.example.com. |
| Heading above them | The line over the list. Empty: no heading. |
| Articles at most | From 1 to 8. 4 at first. |
| Say in the mail which articles they saw | On at first. See below. |
How articles are found
WordPress’s search wants every word in one post, so a whole sentence finds nothing. Suggested answers keeps the telling words of what was typed (no “how”, “please” or “the”, 3 letters or more), looks each one up, and puts first the articles that hold the most of them; a word in the title counts twice. Another site’s answers are kept for six hours, so typing the same thing again asks it nothing.
A visitor can search 60 times in ten minutes, so the search can’t be used to load your server.
What you get in the mail
Someone who writes anyway saw articles that didn’t answer: worth a look. With Say in the mail which articles they saw on, the list goes at the end of the mail, in the entry and in the webhooks (as suggested_answers: title, url, opened), and articles they clicked say (opened). Put [_suggested_answers] in the mail to have it somewhere else.
Change how it looks
Two templates, each copied to your theme to change it:
fields/answers/default/field.php: the Suggested answers field, the place the articles show. Keep itsdata-remaily-answers-box: the script fills that box.suggested-answers/list.php: the list itself, styled bysuggested-answers/style.cssin your form’s colors. Keepdata-remaily-answeron each link: it’s how the script sees which ones were opened.
Copy them to your-theme/remaily/ under the same paths.
For developers
| Hook | What it does |
|---|---|
remaily_suggested_answers | The articles found: ( $found, $text, $settings ), each [ 'title', 'url', 'excerpt' ]. Reorder them, add your own, or return none. |
remaily_suggested_answers_stopwords | Words left out of the search, lowercase. Add your site’s language. |