Title: Выделение поисковых запросов
Author: Rolf Allard van Hagen
Published: <strong>14.04.2009</strong>
Last modified: 02.04.2026

---

Поиск плагинов

![](https://ps.w.org/highlight-search-terms/assets/banner-772x250.png?rev=1112135)

![](https://ps.w.org/highlight-search-terms/assets/icon-128x128.png?rev=1112135)

# Выделение поисковых запросов

 Автор: [Rolf Allard van Hagen](https://profiles.wordpress.org/ravanh/)

[Скачать](https://downloads.wordpress.org/plugin/highlight-search-terms.1.8.3.zip)

[Предпросмотр в реальном времени](https://ru.wordpress.org/plugins/highlight-search-terms/?preview=1)

 * [Детали](https://ru.wordpress.org/plugins/highlight-search-terms/#description)
 * [Отзывы](https://ru.wordpress.org/plugins/highlight-search-terms/#reviews)
 * [Разработка](https://ru.wordpress.org/plugins/highlight-search-terms/#developers)

 [Поддержка](https://wordpress.org/support/plugin/highlight-search-terms/)

## Описание

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](http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/)
and [Search Hilite by Ryan Boren](https://wordpress.org/extend/plugins/google-highlight/).
It has since evolved with many optimizations, HTML5 and bbPress support.

Начиная с версии 1.6 он больше не зависит от библиотеки jQuery.

**Функции**

 * Выделение по щелчку: выделение не только на странице результатов поиска WP, но
   и на один клик глубже на любой из найденных страниц.
 * Character and case insensitive (lenient) highlighting
 * Совместимость с BuddyPress / bbPress: выделение при поиске по форуму
 * Совместимость с кэшированием (WP Super Cache)
 * Search terms wrapped in double quotes now considered as single term

#### Что оно делает?

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.

#### Что НЕ делает?

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.

#### Итак, что мне нужно сделать?

В большинстве случаев он должен просто работать. Но вы можете сделать две вещи, 
чтобы обеспечить обратную совместимость с браузером и темой:

 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](https://wordpress.org/plugins/highlight-search-terms/#faq).
 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](https://wordpress.org/plugins/highlight-search-terms/#faq)
    for ways to make it work.

#### Доступные хуки и фильтры

 1. `hlst_query_vars` — Массив переменных запроса WordPress, которые плагин идентифицирует
    как поисковый запрос. Должен возвращать массив. Дефолт: `['search_terms','bbp_search']`(
    WordPress и bbPress поиск)
 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.

#### Известные проблемы & разработка

 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](https://wordpress.org/extend/plugins/highlight-search-terms/faq/)
    for an explanation.
 2. [Josh](http://theveganpost.com) 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!

Пожалуйста, отправляйте отчеты об ошибках и вклады в код в виде запросов на вытягивание
на [GitHub](https://github.com/RavanH/highlight-search-terms).

## Скриншоты

 * [[
 * Example of search term highlighting with the default MARK tag.
 * [[

## Часто задаваемые вопросы

### Инструкция по установке

To make it work, you will need to take up to three steps, depending on your wishes
and WordPress theme. (I) A normal installation and activation procedure; (II) Make
sure your theme uses any of the recognized classes or ID’s for the post content 
div so that the script knows where and where not to look for search terms;
 _and_(
III) optionally add CSS styling rules to get highlighting for older browsers that
do not support HTML5 like Internet Explorer 8 and below.

**I.** [Install now](http://coveredwebservices.com/wp-plugin-install/?plugin=highlight-search-terms)
_or_ use the slick search and install feature (Plugins > Add New and search for «
highlight search terms») in your WP2.7+ admin section _or_ follow these basic steps.

 1. Скачать архив и распаковать.
 2. Загрузите (и перезапишите) папку /highlight-search-terms/ и ее содержимое в папку/
    plugins/.
 3. Активируйте плагин на странице Плагины

**II.** In most up to date themes (including WP’s own Default theme) post and page
content is shown inside an `ARTICLE` element or `DIV` with class `hentry`.
 This
is recognized by the hilite script, which means search terms found in post and page
content will be highlighted but _not_ similar terms that coincidentally reside in
the page header, menu, sidebar or footer.

If your current theme does not use these common designations (yet), this plugin 
will look for some other possible tags like `#content`, `MAIN`, `#wrapper` (which
might include the header, sidebar and footer areas) and finally the `BODY`.

If this causes issues on your theme, see the last of the [FAQ’s](https://wordpress.org/plugins/highlight-search-terms/#faq)
for ways to make it work.

**III.** Optionally add at least _one_ new rule to your themes stylesheet or the
Custom CSS editor to style highlightable text.

For example use `.hilite { background:#D3E18A; }` to get a moss green background
on search terms found in the content section (not header, sidebar or footer; assuming
your Theme uses a div with class «hentry»).

Please find more examples in the FAQ’s below.

### Я не вижу никакой подсветки!

This plugin has _no_ configuration options page and there is _no_ predefined highlight
styling. For any highlighting to become visible in browsers that do not support 
HTML5 like Internet Explorer 8 or older, you have to complete step III of the installation
process.
 Edit your themes stylesheet (style.css) or the WordPress theme customizer
Custom CSS tab to contain a rule that will give you exactly the styling that fits
your theme.

If that’s not the issue, then you might be experiencing a bug or plugin/theme conflict.
Time to get some [Support](https://wordpress.org/support/plugin/highlight-search-terms/)
🙂

### Я хочу настроить подсветку, но понятия не имею, что добавить в свою таблицу стилей. Можете ли вы привести несколько примеров?

Перейдите в раздел администратора WP на Внешний вид > Настроить > Пользовательский
CSS и добавьте один из приведенных ниже примеров, чтобы начать работу.

For a moss green background highlighting:

    ```
    .hilite {
        background-color: #D3E18A;
    }
    ```

Подсветка желтым фоном:

    ```
    .hilite {
        background-color: yellow;
    }
    ```

Светло-голубой фон с жирным шрифтом:

    ```
    .hilite {
        background-color: #9CD4FF;
        font-weight: bold;
    }
    ```

Оранжевый фон с черным шрифтом:

    ```
    .hilite {
        background-color:#FFCA61;
        color: #000000;
    }
    ```

### Please give me more advanced CSS examples

If you want to give different terms used in a search phrase a different styling,
use the class «term-N» where N is a number starting with 0, increasing 1 with each
additional search term, to define your CSS rules.
 The below example will make every
instance of any term used in the query show up in bold text and a yellow background
except for any instance of a second, third and fourth term which will have respectively
a light green, light blue and orange background.

    ```
    /* Default highlighting, but bold text. */
    .hilite {
        background-color: yellow;
        font-weight: bold;
    }
    /* Moss green highlighting for second search term only. */
    .term-1 {
        background-color: #D3E18A;
    }
    /* Light blue highlighting for third search term only. */
    .term-2 {
        background-color: #9CD4FF;
    }
    /* Orange highlighting for fourth search term only. */
    .term-3 {
        background-color:#FFCA61
    }
    ```

Keep in mind that for the _first_ search term the additional class «term-0» is used,
not «term-1»!

### Terms outside my post/page content get highlighted too

The script will search through your page source code for viable sections that usually
contain page or post content, most commonly used in WordPress themes. Like ARTICLE
or a DIV with class «hentry». If that is not available, the script will look for
other commonly used divs like #content, #main, #wrapper. However, in your particular
theme, none of these divs might be available…

Let’s suppose your theme’s index.php or single.php has no `<div <?php post_class()?
> ... >` but wraps the post/page content in a `<div id="someid" class="someclass"
> ... </div>`. This will not be recognized by the script as a post/page content 
container and the script will default to highlighting starting with the BODY element.

Это приведет к выделению терминов в заголовке, меню, боковой панели и нижнем колонтитуле.

Вы можете сделать одну из трех вещей, чтобы решить эту проблему:

A. Change your theme templates like single.php, page.pho and search.php so the post/
page content div has a class «hentry» (you can append it to existing classes with
a space like `class="someclass hentry"`).

B. Добавьте фильтр в файл functions.php вашей темы (или отдельный файл плагина) 
следующим образом:

    ```
    add_filter(
        'hlst_selectors',
        function( $selectors ) {
            // custom theme selectors (change and append as needed)
            $my_selectors = array(
                'div.someclass'
            );
            return $my_selectors + (array) $selectors;
        }
    );
    ```

C. Переключитесь на тему, которая соответствует текущим соглашениям WordPress 🙂

## Отзывы

![](https://secure.gravatar.com/avatar/975d4a35d74f3a6df8b34e39db55945e4445416f7a0b2d1b1b3cf92c9b97abbd?
s=60&d=retro&r=g)

### 󠀁[Easy Install and works!](https://wordpress.org/support/topic/easy-install-and-works-2/)󠁿

 [hexoliving](https://profiles.wordpress.org/hexoliving/) 24.05.2024

Nice plugin — highly reccomend.

![](https://secure.gravatar.com/avatar/cc6790afcae10f85481e673c9127c4b502d5af9b056d9b0b4f2a2e488c799c1b?
s=60&d=retro&r=g)

### 󠀁[Very Nice and useful](https://wordpress.org/support/topic/very-nice-and-useful-22/)󠁿

 [mauri01](https://profiles.wordpress.org/mauri01/) 04.04.2024

I added the «Prevent highlighting when clicking through to result» option, all works
well! Thanks you

![](https://secure.gravatar.com/avatar/b8b5d05f16c9f7a56e2e008a523e8bbb27f52a91f8692e8265f2831d7063f2d7?
s=60&d=retro&r=g)

### 󠀁[Great Plugin | Works Flawlessly](https://wordpress.org/support/topic/great-plugin-works-flawlessly-10/)󠁿

 [Generosus](https://profiles.wordpress.org/generosus/) 14.09.2023

Nice! A plugin that works «out of the box.» Note: If after installing this plugin
you experience any issues, most likely, they are due to a conflict with another 
plugin (usually a Cache or Performance plugin). The developers of these other plugins
should be able to help solve your issues. Cheers 🙂

![](https://secure.gravatar.com/avatar/80a534128862c6505ff025cbd2dea9e35001bd2ad6e861b802623c648b8eadc8?
s=60&d=retro&r=g)

### 󠀁[Very good and helpful, but there is a bug.](https://wordpress.org/support/topic/very-good-and-helpful-but-there-is-a-bug/)󠁿

 [j0p2021](https://profiles.wordpress.org/j0p2021/) 29.08.2023 1 ответ

Very good. It didn’t work right away. But overall very helpful. Although I immediately
found a small mistake. For some reason, «by» does not work, but «by» = «by» — I 
checked! 1.cbm.ua/?p=5504

![](https://secure.gravatar.com/avatar/40ed8fbfd8cfa5796405e80c0469600d5c066de3eb781d6b72697c1777a11e30?
s=60&d=retro&r=g)

### 󠀁[Still working like a charm](https://wordpress.org/support/topic/still-working-like-a-charm/)󠁿

 [BPhDesigns](https://profiles.wordpress.org/bphdesigns/) 03.03.2023

Thanks for this great simple plugin.

![](https://secure.gravatar.com/avatar/8e1aa937a48cd6848c41c2e9176222de43a6c50eb66a21dcb71ed2bccb1b9dde?
s=60&d=retro&r=g)

### 󠀁[Latest update broke my site…](https://wordpress.org/support/topic/latest-update-broke-my-site-22/)󠁿

 [backfolder](https://profiles.wordpress.org/backfolder/) 01.02.2022 8 ответов

Latest update 1.8.0 broke my site…

 [ Посмотреть все 40 отзывов ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/)

## Участники и разработчики

«Выделение поисковых запросов» — проект с открытым исходным кодом. В развитие плагина
внесли свой вклад следующие участники:

Участники

 *   [ Rolf Allard van Hagen ](https://profiles.wordpress.org/ravanh/)

«Выделение поисковых запросов» переведён на 3 языка. Благодарим [переводчиков](https://translate.wordpress.org/projects/wp-plugins/highlight-search-terms/contributors)
за их работу.

[Перевести «Выделение поисковых запросов» на ваш язык.](https://translate.wordpress.org/projects/wp-plugins/highlight-search-terms)

### Заинтересованы в разработке?

[Посмотрите код](https://plugins.trac.wordpress.org/browser/highlight-search-terms/),
проверьте [SVN репозиторий](https://plugins.svn.wordpress.org/highlight-search-terms/),
или подпишитесь на [журнал разработки](https://plugins.trac.wordpress.org/log/highlight-search-terms/)
по [RSS](https://plugins.trac.wordpress.org/log/highlight-search-terms/?limit=100&mode=stop_on_copy&format=rss).

## Журнал изменений

#### 1.8.3

2024-04-05
 * Update to WP coding standards * WP 6.5 compatibility tested

#### 1.8.2

Date 2022-03-01

 * Fix T_TRY error

#### 1.8.1

Date 2022-01-31

 * Fix possible missing is_plugin_active error

#### 1.8.0

Date 2022-01-30

 * NEW: Woocommerce compatibility
 * NEW: Search Filter Pro compatibility

#### 1.7.0

Дата 2021-12-04

 * Switch to mark.js, https://markjs.io/
 * Include HTML5 main tag
 * Dropped futile search engine support
 * FIX: Possible double inline script
 * FIX: wptexturized search results not highlighted
 * NEW: filter hlst_events

#### 1.6.1

Дата 2021-08-18

 * FIX: NinjaFirewall incompatibility, thanks @danielrufde

#### 1.6

Дата 2021-06-22

 * NEW: Vanilla Javascript, no more jQuery dependency!
 * NEW: Arabic character normalization map. Thanks @khakan
 * NEW: Jetpack Infinite Scroll support

#### 1.5.8

Date 2021-06-20

 * NEW: filters hlst_query_vars, hlst_inline_script and hlst_input_get_args

#### 1.5.7

Date 2021-06-10

 * FIX: broken comment pagination links, thanks @tooni

#### 1.5.6

Дата 2021-01-13

 * ИСПРАВЛЕНИЕ: несовместимость jQuery 3

#### 1.5.5

Дата 2020-04-07

 * ИСПРАВЛЕНИЕ: повторное рассмотрение уязвимости XSS

#### 1.5.4

Дата 2020-04-02

 * Предотвратить выделение при поиске по клику из пунктов меню или виджетов

#### 1.5.3

Дата 2019-12-20

 * Улучшение совместимости сторонних поисковых плагинов

#### 1.5.2

Дата 2019-03-07

 * ИСПРАВЛЕНИЕ: результаты с учетом кириллического регистра, спасибо @dimmez
 * Сжатие скрипта

#### 1.5

Дата 2018-03-10

 * Перейти к wp_add_inline_script

#### 1.4.7

Дата 2017-12-22

 * Исправлена возможная уязвимость в append_search_query()
 * Подготовить текстовый домен перевода

#### 1.4.5

Дата 2017-11-23

 * ИСПРАВЛЕНИЕ: Предотвращение bbp_is_search() для администратора, запускаемого 
   Gravity Forms, о чем сообщает @dicoeenvoud.

#### 1.4.4

Дата 2017-02-24

 * ИСПРАВЛЕНИЕ: уязвимость XSS, о которой сообщил Бен Биднер @ Automattic

#### 1.4.3

Дата 2017-01-31
 Время разработки: 3 часа

 * ИСПРАВЛЕНИЕ ОШИБКИ: оператор [] не поддерживается для строк в PHP 7, спасибо 
   @seppsoft
 * Drop pre WP 3.7 support
 * Улучшенная поддержка bbPress

#### 1.4.2

Дата 2016-10-04
 Время разработки: 3 часа

 * BUGFIX: use filtered search terms for click through highlighting

#### 1.4.1

Дата 20.07.2016
 Время разработки: 2 часа

 * BUGFIX: incompatibility with Relevanssi and other search plugins

#### 1.4

Date 2016-04-10
 Dev time: 6h

 * Лучшие результаты поиска
 * Improved bbPress compatibility
 * Renamed Minified js

#### 1.3.9.1

Date 2015-10-13
 Dev time: 1h

 * FIX: Missing terms not wrapped in P tag (reported by zmokin)

#### 1.3.9

Date 2014-09-04
 Dev time: 5h

 * Совместимость с поиском WordPress 3.8, позволяющая менее нечеткий поиск с кавычками
 * ?sentence=1 query parameter compat
 * FIX: XSS vulnerability found by [Rodolfo Godalle, Jr.](http://www.facebook.com/junior.ns1de)

#### 1.3

Date 2013-09-02
 Dev time: 2h

 * BuddyPress and bbPress highlighting within forum searches
 * Исправлено: jQuery 1.10 совместимость

#### 1.2.5

Date 2013-07-28
 Dev time: 1h

 * FIX: Combine-JS compatibility (Thanks to Joshua Hoke)
 * More possible classes and ids to look for

#### 1.2.4

Date 2012-12-16
 Dev time: 1h

 * BUGFIX: non-western languages in URL not decoded

#### 1.2.3

Date 2012-12-06
 Dev time: 1h

 * BUGFIX: javascript infinite loop

#### 1.2.2

Date 2012-10-11
 Dev time: 6h

 * Search terms wrapped in double quotes now considered as single term
 * Caching compatible
 * Second click highlighting: not only on the search results page but also inside
   any of the found pages
 * Speed improvement
 * More search engines supported
 * BUGFIX: Undefined variable: cache_compat

#### 1.2.1

Date 2012-07-27
 Dev time: 1h

 * BUGFIX: non HTML5 browser (IE8 and older) support failing

#### 1.2

Date 2012-07-25
 Dev time: 8h

 * NEW: Caching (WP Super Cache) compatibility
 * NEW: Highlights not only on WP search results page but also one click deeper 
   inside any of the found pages
 * NEW: Search terms wrapped in double quotes now considered as single term
 * support many more search engines: AOL, Dogpile, Search.com, Goodsearch.com, Mywebsearch.
   com, Webcrawler.com, Info.com
 * rebuilt as Class
 * plugin speed improvements

#### 0.8

Date 2012-04-18
 Dev time: 2h

 * HTML5 mark tag support
 * No more word boundary limit for non-latin based languages compatibility

#### 0.7

Date: 2011-01-03
 Dev time: 1h

 * BUGFIX: conflict with Cufon script

#### 0.6

Date: 2010-09-06
 Dev time: 2h

 * limit highlighted search terms to word boundary
 * added Bing, Ask, Baidu and Youdao search engines
 * now automatically check for and highlights in multiple theme div areas
 * BUGFIX: cloning first result excerpt to all excerpts

#### 0.5

Date: 2010-08-07
 Dev time: 2h

 * using jQuery in no-conflict mode and $hlst instead of $ to avoid conflict with
   prototype
 * split variables and moved js extension in compacted form to static file
 * moved jQuery and extention to footer + only when actually needed for faster page
   load

#### 0.4

Date: 2010-04-07
 Dev time: 1h

 * fixed Regular Expression to allow parts of words to be highlighted
 * search term wrapping limited to .hentry divs

#### 0.3

Дата: 2009-04-16
 Время разработки: 1 час

 * Bugfix for Firefox 2+ (forcefully highlights now limited to div#content)

#### 0.2

Дата: 2009-04-15
 Время разработки: 1 час

 * Разрешение нескольких стилей поискового запроса
 * Исправление для IE7 / IE8, спасибо [Jason](https://wordpress.org/support/profile/412612)

#### 0.1

Дата: 2009-04-14
 Время разработки: 3 часа

 * Basic plugin aimed at low impact / low resource demand on your WP installation
   using client side javascript.

## Мета

 *  Версия **1.8.3**
 *  Обновление: **2 недели назад**
 *  Активных установок: **7 000+**
 *  Версия WordPress ** 3.7 или выше **
 *  Совместим вплоть до: **6.8.5**
 *  Версия PHP ** 5.6 или выше **
 *  Языки
 * [Dutch](https://nl.wordpress.org/plugins/highlight-search-terms/), [English (US)](https://wordpress.org/plugins/highlight-search-terms/),
   [Greek](https://el.wordpress.org/plugins/highlight-search-terms/) и [Russian](https://ru.wordpress.org/plugins/highlight-search-terms/).
 *  [Перевести на ваш язык](https://translate.wordpress.org/projects/wp-plugins/highlight-search-terms)
 * Метки:
 * [Highlight](https://ru.wordpress.org/plugins/tags/highlight/)[mark](https://ru.wordpress.org/plugins/tags/mark/)
   [search](https://ru.wordpress.org/plugins/tags/search/)[Search Terms](https://ru.wordpress.org/plugins/tags/search-terms/)
 *  [Дополнительно](https://ru.wordpress.org/plugins/highlight-search-terms/advanced/)

## Оценки

 5 из 5 звёзд.

 *  [  39 5-звездный отзыв     ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/?filter=5)
 *  [  1 4-звездный отзыв     ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/?filter=4)
 *  [  0 3-звездный отзыв     ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/?filter=3)
 *  [  0 2-звездный отзыв     ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/?filter=2)
 *  [  0 1-звездный отзыв     ](https://wordpress.org/support/plugin/highlight-search-terms/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/highlight-search-terms/reviews/#new-post)

[Посмотреть всеотзывы](https://wordpress.org/support/plugin/highlight-search-terms/reviews/)

## Участники

 *   [ Rolf Allard van Hagen ](https://profiles.wordpress.org/ravanh/)

## Поддержка

Решено проблем за последние 2 месяца:

     1 из 1

 [Перейти в форум поддержки](https://wordpress.org/support/plugin/highlight-search-terms/)

## Пожертвование

Хотите поддержать улучшение этого плагина?

 [ Пожертвовать на развитие плагина ](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=Highlight%20Search%20Terms&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8)