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.
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.
Also included
- Automatic insertion for themes without the template editor: the blocks can be placed without touching the theme.
- A search log in a dedicated table: date, term, results, tolerance and IP address, with optional anonymisation and automatic purge.
- Caching of the block output, invalidated at each publication.
Screenshots taken on a demo site, with content produced for the demonstration.
Requirements and installation
- WordPress 6.1 or later, PHP 7.2 or later.
- French admin interface.
- Upload
hkc-blocks.zipfrom Plugins › Add New › Upload Plugin. - Activate it, then add the blocks in the editor. Settings live in Settings › HKC Blocks, one tab per block.