HKC Blocks

Three blocks for editorial blogs, all computed in PHP: no JavaScript for your visitors, no external resource, no build step.

Fuzzy search

A search field that forgives typos. The visitor lands on the usual results page of the theme, but the ranking is replaced: exact matches first, from the most occurrences to the fewest and then newest first, approximate matches next, from closest to furthest.

Proximity uses the Damerau-Levenshtein distance, which counts swapping two neighbouring letters as a single mistake: for the query “kabal”, “kabla” (one swap, same length) ranks ahead of “kabbal” (one insertion, one letter more). Titles, excerpts and full content of posts and pages are searched. Typo tolerance is a block setting: strict, normal or wide.

A search for “corre web vitale” on the front end, returning the post about Core Web Vitals.
“corre web vitale”, with two typos: the post about Core Web Vitals comes back all the same.

Related posts

To place under a post: it shows the closest posts, measured on the content itself — without relying on categories or tags, often unevenly maintained on an old blog.

The characteristic words of the current post are extracted (the most frequent ones, stop words removed), posts containing them are scored, and the best come out. A word in a title weighs four times a word in the body, a very long post is dampened so it cannot win by length alone, and two shared words beat one repeated word. Settings: section title, number of posts, thumbnail, date, excerpt.

Term index

The terms your blog really talks about — 500 by default — paginated by letter. Each term leads to the posts that mention it, with three figures: occurrences, number of posts, and the share of the blog that represents (“43 posts” out of 500 published gives 8.6 %).

Several filters keep the index honest: stop words and very short words, French verb forms, variants merged to their base form (singular rather than plural, noun rather than derived adjective), proper nouns keeping their capital, multi-word expressions indexed as such (“Emmanuel Macron”, “agence de communication”), and terms present in too large a share of posts — which is how recopied mentions disappear: signature, subscription call, section labels. Menus, sidebars and theme templates are never read: only post content.

The computation runs once, is stored in the database and refreshed each night. The settings page reports the number of terms kept, posts scanned, and the date and duration of the last run.

A page carrying the three blocks: the search field, four related posts, and the alphabetical term index.
The three blocks on one page: search field, related posts, and the alphabetical index of terms.

Also included

The settings screen, Search history tab: retention, IP setting, and the most searched terms with their number of results.
The search log: what readers look for, and what they do not find — “wordpress 2026”, no result.

Screenshots taken on a demo site, with content produced for the demonstration.

Requirements and installation

  1. Upload hkc-blocks.zip from Plugins › Add New › Upload Plugin.
  2. Activate it, then add the blocks in the editor. Settings live in Settings › HKC Blocks, one tab per block.