-
Notifications
You must be signed in to change notification settings - Fork 0
Configuring superwords
Superwords are ment for lifting handful of content pages with
different superwords. For example lifting page http://www.site.test/summer-vacation
when using search terms "vacation", "holiday"
as the most important search result.
Pages can expose superwords by two different ways:
- Using
wp-valu-search
plugin filters - Using data-attributes recognized by the scraper
wp-valu-search
filter is placed in php-code.
Valu Search crawler scrapes contents from HTML DOM elements with
specific attributes. For superwords this attribute is
data-vs-superwords
Note: If all pages have superwords, no page is special. Pages can have any number of superwords, but this is not what superwords is meant to be used for. Careless superword usage can worsen the end user user-experience.
- Add
valu_search_superwords
wp-filter
function example_superwords_rewrite( $superwords, $post ){
// modify superwords based on post
if(get_permalink($post) !== "<url you want to target here>"){
return $superwords;
}
$superwords = [
'your-secondary-superword-here',
'your-superword-here',
];
return $superwords;
}
add_filter( 'valu_search_superwords', 'example_superwords_rewrite', 10, 2 );
-
Change url you want to target in example code
-
Validate filter functionality by navigating to
<url you want to target here>/?_vsid
_vsid
is a query parameter send by Valu Searchcrawler, andwp-valu-search
plugin exposes data on page in a script tag.In browser developer tools, search for
valu-search
on the page. You should find a script tag like this:<script type="application/json" id="valu-search"> {"showInSearch": ..., ... "superwords":["your-superword-here", "your-secondary-superword-here"], ... </script>
-
Done! After next crawl the page will have the superwords you specified and should be the first search result with any superwords you specified
Scraper looks for elements with data-vs-superwords
data-attribute and their contents.
<div data-vs-superwords>superword</div>
<span data-vs-superwords>more<span>
results in:
["superword","more"]
Multiple words in single element separated with spaces are separated into their own superwords
<div data-vs-superwords>superword1 superword2 superword3</div>
results in:
["superword1", "superword2", "superword3"]
Element that holds the custom fields does not need to be visually
visible. It can be hidden with style="display:none;"
or in some other way.
Element holding the superwords can be located anywhere on the webpage.