Relevanssi Premium 2.4.4 introduced a new feature where you can target specific parts of the post straight from the search terms. The format for this is
{target:search_term}
Target can be one of the following:
- title: Post title.
- content: Post content.
- author: Author display name.
- comment: Comment text.
- link: Link from another post.
- excerpt: Post excerpt.
- media: Attachment content (coming in the next version).
- taxonomy slug: Taxonomy name (use
tagorpost_tagfor tags,categoryfor categories and the taxonomy slug for other taxonomies). - custom field name: Custom field name.
These are all compared against Relevanssi index, so you can use any of these targets only if Relevanssi indexes that particular type of content: if you want to, say, target excerpts, you need to make sure Relevanssi is set to index the excerpt.
The search term must be a single word, so if you want to target multiple words, use a specifier for each word separately. Phrases are supported.
Examples:
Search for word “cat” in titles only:
{title:cat}
Search for word “dog”, but only in tags:
{tag:dog}
Search for posts that have the word “knizia” in the taxonomy “designers” and the word “dutrait” in the taxonomy “illustrators”:
{designers:knizia} {illustrators:dutrait}
Note that for multiple targeted terms, you need to have a space between the terms.
Search for posts that have the phrase “Reiner Knizia” in the taxonomy “designers”:
{designers:"reiner knizia"}