How to Add llms.txt to WordPress (Plugin and Manual Methods)

Summary

WordPress has three llms.txt paths — plugin, functions.php, or hosted snippet. Plus caching plugin gotchas (W3 Total Cache, WP Rocket) and .htaccess tips.

Contents

Key facts


Open your WordPress admin, click around for ten minutes, and you'll notice something: there is no place to add llms.txt. Not in Settings → General. Not in Yoast SEO. Not in Rank Math. As of mid-2026 the major SEO plugins still don't ship a llms.txt generator — though several have it on the roadmap and the smaller AI-SEO plugins have started filling the gap. That mismatch (43% of the web runs WordPress, and the platform has zero first-class support for the file every AI client wants) is the whole reason this post exists.

This guide covers the three install paths that work on WordPress in 2026: a plugin, a functions.php hand-roll, and a hosted snippet. Plus the WordPress-specific failure modes — caching plugins serving stale files, .htaccess rules intercepting the path, multisite quirks, and the WooCommerce question. If you need a primer on the file format itself, read what llms.txt is and how AI clients use it first.

The WordPress-specific challenge

WordPress feels like it should make this easy — you can write to the file system, you have a templating system, you have plugins for everything. In practice four things go wrong:

Each install path below handles these constraints differently.

What should be in your WordPress llms.txt

Before picking an install path, decide what goes in the file. For a typical WordPress site, the high-value sections are:

  1. H1 + blockquote. Site name and one-sentence description.
  2. About / contact. The pages that answer "who are you" and "how do I reach you" — agents fetch these constantly.
  3. Top categories. Your 5-10 most active categories. Each with a sentence about the topic.
  4. Top posts. Your 20-50 most-trafficked or most-linked posts. Pick them by analytics, not by recency.
  5. Cornerstone content. The pillar guides or definitive posts you'd want an AI to cite. Mark these with strong descriptions.
  6. Products (if WooCommerce). Top categories, top sellers. Not every SKU.

The target file size is 30-80KB of markdown. That's roughly 60-150 links with descriptions. If your site has more than that, curate.

Path 1 — Plugin install

The lowest-effort path if a maintained plugin exists for your needs. As of mid-2026 the situation is in flux: the major SEO plugins (Yoast, Rank Math, SEOPress, All in One SEO) have not yet shipped first-class llms.txt generators, though feature requests are open on all four. A handful of smaller AI-focused plugins have filled the gap — search the WordPress plugin directory for "llms.txt" and you'll find them.

What to evaluate when picking a plugin:

The honest framing: as of 2026 the plugin path on WordPress is the most variable. The good plugins work. The mediocre ones produce a file that exists at a URL agents don't check and gets cached for a week. Check reviews, check the changelog, install on staging first.

Path 2 — functions.php manual approach

For a developer-comfortable site without a plugin you trust, write a small handler in functions.php (or a custom plugin file — recommended over editing the theme directly). The pattern: register a URL, intercept the request, fetch the data you want, emit markdown with the right content-type.

Here's a minimum working version. Drop this into a custom plugin file or your theme's functions.php:

<?php
add_action('init', function() {
    add_rewrite_rule('^llms\.txt$', 'index.php?llms_txt=1', 'top');
    add_rewrite_tag('%llms_txt%', '([0-9]+)');
});

add_action('template_redirect', function() {
    if (!get_query_var('llms_txt')) {
        return;
    }
    header('Content-Type: text/markdown; charset=utf-8');
    header('Cache-Control: public, max-age=86400');

    $site = get_bloginfo('name');
    $desc = get_bloginfo('description');
    $url  = home_url();

    echo "# {$site}\n\n";
    echo "> {$desc}\n\n";

    echo "## About\n";
    echo "- [{$site}]({$url}): {$desc}\n\n";

    $top_posts = get_posts([
        'posts_per_page' => 30,
        'orderby'        => 'comment_count',
        'order'          => 'DESC',
        'post_status'    => 'publish',
    ]);
    echo "## Posts\n";
    foreach ($top_posts as $p) {
        $excerpt = wp_strip_all_tags(get_the_excerpt($p));
        $excerpt = mb_substr($excerpt, 0, 160);
        echo "- [{$p->post_title}](" . get_permalink($p) . "): {$excerpt}\n";
    }
    exit;
});

After installing, visit Settings → Permalinks and click Save — this flushes WordPress's rewrite rules and registers the new /llms.txt route. Then verify with curl -I https://yoursite.com/llms.txt. You should see a 200 and Content-Type: text/markdown; charset=utf-8.

This is the minimum viable version. A production version would: add category sections, include cornerstone pages, exclude noindex posts, cache the output for an hour to avoid hammering the DB on every fetch, and emit llms-full.txt as a companion route.

Downsides: you own the maintenance. Every time you change content strategy you're editing PHP. And if a cache plugin is in front of WordPress, the response gets cached and your regeneration logic doesn't matter.

Path 3 — Hosted snippet via Crawlytics

The third path skips both the plugin and the PHP. Crawlytics crawls your WordPress sitemap (every modern WP install exposes /sitemap_index.xml or /sitemap.xml via Yoast, Rank Math, or core), scores each URL on six signals, and writes llms.txt and llms-full.txt to stable URLs that you point a single redirect at.

The mechanical advantage on WordPress specifically: the files live outside your cache layer entirely. Your WP Rocket, W3 Total Cache, or LiteSpeed Cache plugin can't serve a stale version because they never see the request — the redirect from /llms.txt hits Crawlytics directly. Updates land instantly, you don't have to remember to purge cache, and you don't have to maintain a custom plugin.

The other advantage is per-bot analytics. WordPress hosts (especially managed ones like WP Engine, Kinsta, Pressable) often don't give you raw access log access. So the grep-the-logs playbook doesn't work — you can't see whether GPTBot, ChatGPT-User, ClaudeBot, or PerplexityBot are fetching your file. Crawlytics logs the fetches at the file level and shows them in a dashboard.

The caching plugin trap

This is the failure mode that catches people most often. You install a plugin or write the PHP handler, verify with curl that the file is correct, and then a week later realize the file in production is from last Tuesday. The cause is your cache plugin.

Each major caching plugin needs /llms.txt (and /llms-full.txt) added to its excluded paths list:

If you're on Path 3 (hosted snippet) this doesn't apply — the file is served from outside your stack so the cache plugin never sees the request. That's the structural reason the hosted path is the most reliable for heavily-cached WordPress sites.

Verification with curl

After install, three checks:

  1. curl -I https://yoursite.com/llms.txt — expect HTTP/2 200 and content-type: text/markdown or text/plain. If you see text/html, your handler isn't setting the header.
  2. curl https://yoursite.com/llms.txt | head -20 — expect the H1, blockquote, and first section to render as raw markdown. If you see HTML chrome, your handler isn't exiting before WordPress wraps the theme.
  3. curl -s https://yoursite.com/llms.txt | grep -c '^- \[' — counts the number of links. For a working file you'd expect this to be at least 20.

For a deeper AI-readiness audit beyond llms.txt, run the free Agent-Ready Grader — it checks robots.txt, sitemap, meta, and llms.txt in one pass.

FAQ

Does Yoast SEO generate llms.txt automatically? As of mid-2026, no. Yoast generates sitemap.xml and meta tags, but does not ship a first-class llms.txt generator. The same is true of Rank Math, SEOPress, and All in One SEO. Feature requests are open on all four — this may change in late 2026.

Will WP Super Cache serve a stale llms.txt? Yes, unless you exclude the path explicitly. Default cache TTL on most plugins is 24 hours minimum, often a week. Add /llms.txt and /llms-full.txt to the rejected URIs list, or use the hosted-snippet path which sidesteps the cache layer entirely.

Can I add llms.txt without editing functions.php? Yes — install a plugin (Path 1) or use a hosted snippet (Path 3). The functions.php path is for developers who want full control; it's not the only option.

What if I'm on WordPress.com (the hosted plan)? Functions.php editing is locked on most WordPress.com plans below Business. The Business and Commerce plans allow plugins. Below that, your only real option is the hosted snippet — point a custom DNS-level redirect from /llms.txt at the Crawlytics file. Free and Personal plans don't expose enough infrastructure to do this cleanly.

Does llms.txt work with WooCommerce product pages? Yes, but with caveats. WooCommerce adds product, category, attribute, and variant URLs — you do not want all of them in the file. Curate down to top categories (10-20) and best-selling products (30-50). The plugin and hosted-snippet paths both let you control this; the functions.php path requires you to write the WooCommerce query yourself.

Related

Written by Crawlytics Team. Crawlytics tracks AI bots, generates llms.txt, and powers WebMCP commerce, all from one snippet on any stack. See how it works →

Cite this page

Related on this site


This page is part of Crawlytics.app. View all pages: llms.txt · llms-full.txt

Site index for AI agents: llms.txt · sitemap