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 and Search Hilite by Ryan Boren. It has since evolved with many optimizations, HTML5 and other plugin compatibility. Since version 1.6 it no longer depends on the jQuery library. Features Click through highlights: Highlights not only on WP search results page but also one click deeper inside a post page Character and case insensitive (lenient) highlighting Caching (WP Super Cache) compatibility Search terms wrapped in double quotes now considered as single term Compatible with: Woocommerce Search Filter Pro BuddyPress bbPress 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 ... 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: 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. 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 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) 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) 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. 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). 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 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. 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.
Top keywords
- search17×2.34%
- page9×1.24%
- terms7×0.96%
- theme7×0.96%
- array6×0.83%
- css6×0.83%
- post6×0.83%
- script6×0.83%
- search terms6×0.83%
- content5×0.69%
- default5×0.69%
- highlights5×0.69%
Relevanssi – A Better Search
Relevanssi replaces the standard WordPress search with a better search engine, with lots of features and configurable options. You’ll get better results, better presentation of results – your users will thank you. This is the free version of Relevanssi. There’s also Relevanssi Premium, which has added features. For more information about Premium, see Relevanssi.com. Do note that using Relevanssi may require large amounts (hundreds of megabytes) of database space (for a reasonable estimate, multiply the size of your wp_posts database table by three). If your hosting setup has a limited amount of space for database tables, using Relevanssi may cause problems. In those cases use of Relevanssi cannot be recommended. Key features Search results sorted in the order of relevance, not by date. Fuzzy matching: match partial words, if complete words don’t match. Find documents matching either just one search term (OR query) or require all words to appear (AND query). Search for phrases with quotes, for example “search phrase”. Create custom excerpts that show where the hit was made, with the search terms highlighted. Highlight search terms in the documents when user clicks through search results. Search comments, tags, categories and custom fields. Multisite friendly. bbPress support. Gutenberg friendly. Advanced features Adjust the weighting for titles, tags and comments. Log queries, show most popular queries and recent queries with no hits. Restrict searches to categories and tags using a hidden variable or plugin settings. Index custom post types and custom taxonomies. Index the contents of shortcodes. Google-style “Did you mean?” suggestions based on successful user searches. Support for WPML multi-language plugin and Polylang. Support for s2member membership plugin, Members, Groups, Simple Membership and other membership plugins. Advanced filtering to help hacking the search results the way you want. Search result throttling to improve performance on large databases. Disable indexing of post content and post titles with a simple filter hook. Premium features (only in Relevanssi Premium) Indexing attachment content (PDF, Office, Open Office). Improved spelling correction in “Did you mean?” suggestions. Searching across multiple sites in the same multisite installation. Search and index user profiles. Search and index taxonomy term pages (categories, tags, custom taxonomies). Search and index arbitrary columns in wp_posts MySQL table. Assign weights to any post types and taxonomies. Assign extra weight to new posts. Let the user choose between AND and OR searches, use + and – operator (AND and NOT). Export and import settings. WP CLI commands. Related posts. Redirects for searches. Thanks Cristian Damm for tag indexing, comment indexing, post/page exclusion and general helpfulness. Marcus Dalgren for UTF-8 fixing. Warren Tape for 2.5.5 fixes. Mohib Ebrahim for relentless bug hunting. John Calahan for extensive 4.0 beta testing.
Top keywords