Relevanssi adds a shortcode to help making links to search results. That way users can easily find more information about a given subject from your blog. The syntax is simple:
This will make the text John Doe a link to search results for John Doe. In case you want to link to some other search term than the anchor text (necessary in languages like Finnish), you can use:
Now the search will be for John Doe, but the anchor says Mr. John Doe.
One more parameter: setting will wrap the search term in quotation marks, making it a phrase. This can be useful in some cases.
Related Posts
Indexing only attributes from shortcodes
...do I go about this? – Duke at Remove shortcode but keep content in X parameter You can’t do this using the Relevanssi shortcode removal because that’s a binary operation: the whole shortcode is kept or removed, and there’s no way to keep only part of the shortcode. However, you...I need to add some custom shortcodes to the list of the “removed” ones (so they don’t show in plain text in the results). However, some of them are built like [shortcode_name text="Need to keep this in results"] and I would like the content in the text parameter to stay in the results. How......the "text" attribute from the shortcode * * @param string $content Post content * * @return string Post content with the shortcode replaced with just the "text" attribute content. */ function rlv_shortcode_attribute( $content ) { return preg_replace( '/\ /im', '\1', $content ); } Since this particular case was about a...
relevanssi_disabled_shortcodes
apply_filters( 'relevanssi_disabled_shortcodes', array $shortcodes ) There are shortcodes that do not work well with Relevanssi. These shortcodes can be blocked from the indexing with this filter hook. Relevanssi disables all shortcodes listed with this hook. Parameters $shortcodes (array) An array of shortcode names to disable. For the default values, see......below. More information When Relevanssi indexes posts, if shortcode expansion is enabled in the Relevanssi indexing settings, Relevanssi removes uncompatible shortcode functions and replaces them with __return_empty_string() to get rid of the shortcodes. If you want to add a new shortcode to the block list, do this: add_filter( 'relevanssi_disabled_shortcodes', function(......$shortcodes ) { return array_merge( $shortcodes, array( 'blocked_shortcode', 'another_shortcode' ) ); } ); Relevanssi Premium users can add blocked shortcodes from the Relevanssi indexing settings. If you only want to disable a shortcode in the excerpt-building – perhaps it works fine in indexing, but messes up excerpts – you can...
Installing Relevanssi and adjusting the settings
...words to the search query and in OR search that works as expected, widening the search. In AND search, it will restrict the search, so it won’t work. Enabling this option will make Relevanssi index the synonyms as part of the post content, making them compatible with AND searches. Index......operator OR search will return all posts where at least one of the search terms appears. AND search will only return posts that have all search terms in them. OR search will prefer posts that have all search terms in them, so in most cases it is the better option.......all on all search forms on the site. If a search form includes the searchblogs parameter, it will override this setting. You still need to modify the search results template to get working permalinks, this (and the next) setting is just a shortcut for setting the searchblogs parameter. Search some...
relevanssi_page_builder_shortcodes
apply_filters( 'relevanssi_page_builder_shortcodes', array $shortcodes, string $context ) Filters out page builder shortcodes that cause garbage data in Relevanssi index and excerpts. Parameters $shortcodes (array) An array of shortcodes to remove. $context (string) The name of the current filter, generally relevanssi_post_content or relevanssi_pre_excerpt_content. More information Page builders like Divi, Visual Composer,......Elementor, Fusion Builder, WPBakery and others use shortcodes to build the page layouts and include elements. These shortcodes can be a problem with Relevanssi, as they can appear in the Relevanssi excerpts and cause Relevanssi to index all kinds of garbage metadata that should not be in the index. To......solve this, Relevanssi removes many of these shortcodes in the indexing and excerpt-building process. For some shortcodes, Relevanssi removes both the tag and the contents (for example et_pb_sidebar, vc_raw_html or fusion_imageframe) and for the rest, Relevanssi only removes the tags. This process happens in the relevanssi_post_content and relevanssi_pre_excerpt_content filter hooks....
Relevanssi indexes excluded posts
Sometimes it can happen the search results include posts from a post type that has been excluded from the index. When that happens, here are things you can check. Are you using Relevanssi? It's ...
Is there a way to show search terms like the shortcode does but in the template?
I want to display the 2 most popular search terms and while I cant find a way to do this automatically, if I can just show two terms in my template file that would work.
There’s no automatic way to do it. Check the Relevanssi source code to see how the “User searches” page is made, you can see the MySQL code to get the most popular search terms.