post-embeddings is a WordPress plugin for sites with a few thousand posts that want related-posts lists and search that go beyond matching words. It is MIT licensed, and v0.1.0 was released on 19 November 2026.
It was written from scratch from an idea, as part of a set of utilities built between 11 and 19 November 2026 by language-model coding agents under the editor’s direction. It has not run on a live site. It uses one of the sibling utilities, packed-vectors, for storage and scanning.
Related-posts lists built from shared tags miss stories filed under different terms. Core search matches words, so a reader who types “fuel price rise” gets nothing from a post headed “Petrol and diesel cost more from Monday”. Embeddings fix both: one vector per post and a cosine comparison between vectors.
The hard part is the work around the maths.
wp post-embeddings backfill, in capped, resumable runs that start with a dry run.post_embeddings_provider filter. The reference adapter speaks the common HTTP embeddings request shape.On save_post and transition_post_status, Indexer hashes the post text (title, excerpt, content with block comments, shortcodes and tags stripped) together with the model key. Unchanged text with a stored vector does nothing. No network call happens in a save.
Drain runs from cron under a lock, takes pending rows oldest first and stops after 20 seconds. Before each call it checks the kill switch, the daily caps and the optional spend meter. Each returned vector is checked for length, finite numbers and a non-zero norm, then normalised and stored as float32. Failures back off from five minutes to twelve hours. An authentication failure pauses the drain.
When a provider reports no token usage, TokenEstimator divides characters by a per-script ratio, about 4 for Latin and 1.5 for Indic scripts. A flat divide-by-four would undercount non-Latin text, and undercounting a budget is the dangerous direction.
For related posts, one primary-key read fetches the vector and the sidecar scan returns count * overfetch hits. PHP then drops the post itself, ineligible posts, other types, near-copies and, optionally, old posts. If the sidecar is missing, corrupt or of another dimension, a chunked table scan serves that request and a rebuild is queued. For search, the query vector is cached under a hash for seven days, and the query text is never stored.
wp post-embeddings backfill --cap=500 --dry-run
wp post-embeddings backfill --cap=500 --yes
wp post-embeddings rebuild
wp post-embeddings related 123
--cap.POST_EMBEDDINGS_DISABLED. Related posts keep serving from stored vectors when it is on.INSERT ... ON DUPLICATE KEY UPDATE, and tested on real MySQL with two connections.There are no open issues. This is v0.1.0. The suite has 114 tests and 794 assertions, including integration tests against a throwaway MySQL 8.0, and the rest run on stubs and a fake provider whose vectors are not semantic. Static analysis and code style checks pass. No real embeddings provider has been used, and CI has not yet run on GitHub.
Requires WordPress 6.4 or later, 64-bit PHP 8.1 to 8.3 with mbstring, and an embeddings API under your own credentials or a self-hosted server. Packed-vectors is not on Packagist yet, so list both repositories in Composer.
{
"repositories": [
{"type": "vcs", "url": "https://github.com/IndianOpinion/packed-vectors"},
{"type": "vcs", "url": "https://github.com/IndianOpinion/post-embeddings"}
],
"require": {"indianopinion/post-embeddings": "^0.1"}
}
The release zip bundles packed-vectors. A real system cron is recommended, because WP-Cron only runs on page views.