This folder is for theme and plugin developers who want to extend Anansi SEO or integrate with it, and for site builders who move custom code over from Rank Math or Yoast SEO. It covers how the plugin is organised, its filters and actions, the PHP functions themes can call, the WP-CLI commands, the REST routes and Abilities, and how to move existing code. Everything here was written against Anansi SEO 0.5.11 and taken from the source code.
Contents
| File | What it covers |
|---|---|
| hooks.md | Every public filter and action, grouped by feature, plus the Rank Math hooks Anansi fires for compatibility. |
| functions.md | anansi_is_active(), breadcrumb functions and shortcodes, meta keys and how to read them. |
| cli.md | All wp anansi … commands with options and examples. |
| rest-and-abilities.md | REST routes under anansi/v1 and the two WordPress Abilities. |
| migration-for-developers.md | Moving custom code from Rank Math or Yoast SEO, and what uninstall removes. |
| theme-integration.md | How a theme steps aside and feeds its own data to Anansi, with full examples. |
How Anansi is organised
Modes: preview and live
Anansi has two modes, stored in the anansi_mode option.
- preview (the default on a new install). Anansi prints nothing for visitors. A signed preview request (a URL with
?anansi_preview=<key>, made by the admin dashboard or bywp anansi preview) shows what Anansi would print, between<!-- anansi-preview -->and<!-- /anansi-preview -->markers, next to what the page prints today. Preview responses are sent with no-cache headers andX-Robots-Tag: noindex, nofollow. - live. Anansi prints its head tags, schema and sitemaps, and runs its redirects.
Switch modes in the dashboard or with wp anansi mode live.
What “in charge” means
Anansi is in charge when the mode is live and no other full SEO plugin is active. The plugins that block it are Rank Math, Yoast SEO, All in One SEO, SEOPress and The SEO Framework. Even in live mode, Anansi waits while one of them is active, so the same tags are never printed twice.
| State | Anansi prints for visitors | anansi_is_active() |
|---|---|---|
| Preview mode | No | false |
| Live mode, another SEO plugin active | No | false |
| Live mode, no other SEO plugin | Yes | true |
| Signed preview request | Only on that request, between markers | false |
Themes and plugins should call anansi_is_active() to decide whether to step aside. Most anansi/… filters on page output only run when Anansi builds that output: when it is in charge, or on a signed preview request.
Modules
Core output lives in includes/ and always loads: head block, meta tags, Open Graph, schema, primary term, news sitemap and video schema. Other features are modules, one folder each under includes/modules/{slug}/:
| Module | Feature |
|---|---|
abilities | WordPress Abilities API (read and update a post’s SEO fields). |
blocks | Rank Math FAQ/HowTo block support and the Google preferred-source link. |
crawlers | robots.txt, AI crawler rules, llms.txt, IndexNow, site verification tags. |
editor | SEO panel in the block editor, classic meta box, term and user fields, list columns. |
google | Google Search Console and YouTube Data API connection. |
last-updated | Optional “Last updated” line in post content (settings in anansi_titles, last_updated_* keys). |
import | Importers, migration snapshots, settings export/import, breadcrumb compatibility shims. |
links | Internal link suggestions. |
redirects | Redirects and the 404 log. |
sitemaps | XML sitemaps, image sitemaps, HTML sitemap, sitemap cache. |
tweaks | Lock modified date, category base, attachment redirects, link attributes, RSS footer. |
Each module’s module.php returns its main object. Class files load only when first used.
Head output
Anansi prints one block in wp_head at priority 1:
<!-- Anansi SEO -->
<title>…</title>
<meta name="description" … />
…
<script type="application/ld+json" class="anansi-schema">…</script>
<!-- /Anansi SEO -->
Tags come from the anansi/head/tags filter. Schema and other blocks are printed on the anansi/head action. In live mode Anansi removes WordPress’s own title, robots and canonical output. See hooks.md.
Read-through meta
Anansi can run on a site without a data migration. When it reads a post, term or user field it tries, in order:
_anansi_{key}(Anansi’s own meta).rank_math_{key}(Rank Math’s meta; fornews_robotsthe key isrank_math_news_sitemap_robots).- Any keys added with the
anansi/meta/sourcesfilter.
The first stored, non-empty value wins. For text fields (title, description, canonical URL and similar), an empty string saved under the _anansi_ key means “cleared on purpose” and stops the read-through. Anansi writes only to _anansi_* keys. It never changes or deletes another plugin’s data. See functions.md.
Options
Settings use Rank Math’s key names inside Anansi’s own options, so a site moved from Rank Math keeps every value. Boolean settings follow Rank Math’s 'on' / 'off' style.
| Option | Holds |
|---|---|
anansi_mode | preview or live. |
anansi_preview_key | Secret for signed preview requests. |
anansi_titles | Titles & Meta and Social settings (Rank Math’s rank-math-options-titles keys). |
anansi_general | General settings: breadcrumbs, links, images, feeds, redirects, verification (Rank Math’s rank-math-options-general keys). |
anansi_sitemap | Sitemap settings (Rank Math’s rank-math-options-sitemap keys). |
anansi_settings | News sitemap and video settings. |
anansi_video | Extra video schema settings. |
anansi_blocks | Preferred-source block settings. |
anansi_crawlers | robots.txt, AI crawler, llms.txt and IndexNow settings. |
anansi_links | Internal link suggestion settings. |
anansi_abilities | The Abilities on/off switch (enabled). |
anansi_google | Google connection settings. |
Read settings through the classes (Anansi_Titles::get( $key ), Anansi_General::get( $key )) rather than the raw option when you can. Both return Rank Math-normalised values ('on' becomes true).
Anansi also creates its own tables: {prefix}anansi_redirects, {prefix}anansi_redirects_index, {prefix}anansi_redirects_index_b, {prefix}anansi_404_log and {prefix}anansi_link_vectors. Their layout is internal.
Rank Math compatibility hooks
Many anansi/… filters have a matching rank_math/… filter that Anansi fires with the same arguments, so theme and plugin code written for Rank Math keeps working after the switch. Anansi fires the Rank Math name only when Rank Math is not active (and for most hooks also on a signed preview request). See hooks.md.
Stability
The hooks, functions, commands and routes documented here are intended to stay. Undocumented hooks, classes and methods may change between releases. Where a hook below is marked low-level or internal, treat it the same way.
Anansi is before version 1.0. If a documented hook has to change, the change will be listed in readme.txt under the version that makes it.
Requirements
- WordPress 6.2 or later (the Abilities need 6.9 or later).
- PHP 7.4 or later.
- Text domain:
anansi-seo. Prefixes:anansi_,Anansi_,ANANSI_, hooksanansi/….