Highlight Search Terms

Por Rolf Allard van Hagen
(40 avaliações)
Baixar
  • Versão:
    1.8.3
  • Última atualização:
    há 2 dias
  • Instalações ativas:
    mais de 7 mil
  • Versão do WordPress:
    3.7 ou maior
  • Testado até o WordPress:
    6.8.5
  • Versão do PHP:
    5.6 ou maior
  • Tags:

Hospedagem WordPress com plugin Highlight Search Terms

Onde posso hospedar o plugin Highlight Search Terms?

Este plugin pode ser hospedado em qualquer provedor que possua WordPress instalado. Recomendamos fortemente utilizar uma empresa de hospedagem seguro, com servidores especializados para WordPress, como o serviço de hospedagem de sites da MCO2.

Hospedando o plugin Highlight Search Terms em uma empresa de hospedagem seguro

A MCO2, além de configurar e instalar o WordPress na versão mais atual para seus clientes, disponibiliza o WP SafePress, um mecanismo exclusivo que protege e otimiza seu site simultaneamente.

Por que a Hospedagem WordPress funciona melhor na MCO2?

A Hospedagem WordPress funciona melhor pois a MCO2 possui servidores otimizados para WordPress. A instalação de WordPress é diferente de uma instalação trivial, pois habilita imediatamente recursos como otimização automática de imagens, proteção da página de login, bloqueio de atividades maliciosas diretamente no firewall, cache avançado e HTTPS ativado por padrão. São recursos que potencializam seu WordPress para a máxima segurança e o máximo desempenho.

Highlights search terms within WordPress generated search results, both on the search results page and on each linked post page itself.

This plugin is light weight and has no options. It started as very simple fusion between How to Highlight Search Terms with jQuery – theme hack by Thaya Kareeson and Search Hilite by Ryan Boren. It has since evolved with many optimizations, HTML5 and bbPress support.

Since version 1.6 it no longer depends on the jQuery library.

Características

  • Click through highlights: Highlights not only on WP search results page but also one click deeper inside any of the found pages
  • Character and case insensitive (lenient) highlighting
  • BuddyPress / bbPress compatibility: highlighting within forum searches
  • Caching (WP Super Cache) compatibility
  • Search terms wrapped in double quotes now considered as single term

What does it do?

This low impact plugin finds all search terms on a search results page inside each post and highlights them with a <mark class="hilite term-N"> ... </mark> tag.
Note that N is a number starting with 0 for the first term used in the search phrase increasing 1 for each additional term used. Any part of a search phrase wrapped in quotes is considered as a single term.

What does it NOT do?

There are no CSS style rules set for highlighting. You are free to use any styling you wish but to make the highlights visible in browsers that do not support HTML5 like Internet Explorer 8 or older you absolutely need to define at least one rule.
Modern HTML5 browsers will use their own highlighting style by default, which usually is a yellow marker style background.

So what do I need to do?

In most cases, it should just work. But you can do two things to ensure backward browser and theme compatibility:

  1. Define CSS rules: There are no configuration options and there is no predefined highlight styling. You are completely free to define any CSS styling rules in your themes main stylesheet (style.css) or the Custom CSS tab if the WordPress theme customizer.
    You can find basic instructions and CSS examples in the FAQ’s.

  2. Check your theme: In most up to date themes (including WP’s own default theme) post and page content is shown inside a div with class hentry. This means search terms found in post and page content will be highlighted but not similar terms that accidentally show in the page header, sidebar or footer.
    If your current theme does not use the hentry class (yet), this plugin will look for IDs content, main and finally wrapper but if none of those are found, it will not work for you out of the box. See the last of the FAQ’s for ways to make it work.

Available hooks and filters

  1. hlst_query_vars – The array of WordPress query variables that the plugin will identify as a search query. Must return an array. Default: ['search_terms','bbp_search'] (WordPress abd bbPress search)

  2. hlst_input_get_args – An array of GET variables that the plugin will identify as a search query. Must return an array. Default: ['hilite'] (for click-through highlighting)

  3. hlst_selectors – The array of possible HTML DOM element identifiers that the script will try. The first viable identifier it finds elements of will be scanned for search terms to mark, the rest is ignored. So the order is important here! Start with the element closest to, but still containing all the post/page title, excerpt or content.

  4. hlst_events – The array of DOM event listeners that the inline script will watch for. Default: ['DOMContentLoaded','post-load'] (on Document Ready and for Jetpack Infinite Scroll and others).

  5. hlst_inline_script – The inline script that will be added to the plugin script file. Can be used to add to or alter the inline script. Must return a string.

Known issues & development

  1. If your theme does not wrap the main content section of your pages in a div with class “hentry” or HTML5 article tags, this plugin might not work well for you out of the box. However, you can make it work. See the last of the FAQ’s for an explanation.

  2. Josh pointed out a conflict with the ShareThis buttons plugin. Since then, that plugin has been completely rewriten so please let me know if the problem still exists. Thanks!

Please file bug reports and code contributions as pull requests on GitHub.

Capturas de tela

Example of search term highlighting with the default MARK tag.

Example of search term highlighting with the default MARK tag.

Highlight Search Terms

Plugins semelhantes

Ivory Search – WordPress Search Plugin
(1.536 avaliações)

Advanced WordPress custom search plugin. Provides Search Form Customizer, WooCommerce Search, AJAX Search & Live Search support!

Relevanssi – A Better Search
(403 avaliações)

Relevanssi replaces the default search with a partial-match search that sorts results by relevance. It also indexes comments and shortcode content.

Search & Replace
(279 avaliações)

Search & Replace data in your database with WordPress admin, replace domains/URLs of your WordPress installation.

String locator
(121 avaliações)

Find and edit code or texts in your themes and plugins

Search Regex
(97 avaliações)

Search Regex adds a powerful set of search and replace functions to WordPress posts, pages, custom post types, and other data.

Ajax Search Lite – Live Search & Filter
(260 avaliações)

The Best Ajax Live Search and Filter for WordPress. Live suggestions, Custom Post types, Custom fields, Categories, WooCommerce & Elementor support

Do mesmo author (Rolf Allard van Hagen)

XML Sitemap & Google News
(83 avaliações)

Take control of your WordPress core XML Sitemap and add a Google News Sitemap.