How to › WordPress (no file access)
Add llms.txt to WordPress when you cannot upload a file
On managed hosting you often cannot put anything in the web root. WordPress can serve the path itself instead — and it already does exactly this twice, for robots.txt and for its own sitemap, which is the pattern to copy rather than invent.
Can this platform serve the file at the exact path?
Yes — WordPress can serve the path itself.
The pattern is core’s own. Sitemaps register their path with add_rewrite_rule (see WP_Sitemaps::register_rewrites), and do_robots is the documented precedent for sending a plain-text body with an explicit content type.
before you start
What you need first
- A place to put a few lines of PHP that survives a theme update: a small site-specific plugin is the safe home, a child theme’s
functions.phpis the common one. - The ability to visit Settings › Permalinks, which is what flushes the rewrite rules.
- The file content itself — the generator will produce it, and you paste it into the code as a string or store it as an option.
the steps
Register the path, answer it in plain text
- Register the rewrite rule on
init.add_rewrite_rule( '^llms\.txt$', 'index.php?llms_txt=1', 'top' ). The documentation for that function notes that any value other thanbottomputs the rule at the top, which is what core does for its sitemap. - Declare the query variable. Add
llms_txtthrough thequery_varsfilter, or WordPress will drop it before your code ever sees it. - Answer it on
template_redirect. When the variable is present, sendContent-Type: text/plain; charset=utf-8, echo the file, andexit. That header is exactly what core’sdo_robots()sends, which is why it is the line to copy. - Flush the rules once. Visit Settings › Permalinks and press Save Changes. The documentation is explicit that visiting the screen triggers the flush, and that
flush_rewrite_rules()is an expensive operation to be called on activation rather than on every request. - Check the URL.
https://yourdomain/llms.txtshould return your text. If it 404s, you have not flushed.
The whole thing, as a site-specific plugin
<?php
/* Plugin Name: llms.txt */
add_action( 'init', function () {
add_rewrite_rule( '^llms\.txt$', 'index.php?llms_txt=1', 'top' );
} );
add_filter( 'query_vars', function ( $vars ) {
$vars[] = 'llms_txt';
return $vars;
} );
add_action( 'template_redirect', function () {
if ( ! get_query_var( 'llms_txt' ) ) {
return;
}
header( 'Content-Type: text/plain; charset=utf-8' );
echo get_option( 'llms_txt_body', "# Your Business\n" );
exit;
} );
register_activation_hook( __FILE__, function () {
add_rewrite_rule( '^llms\.txt$', 'index.php?llms_txt=1', 'top' );
flush_rewrite_rules();
} );
what breaks it
The ways this goes wrong on WordPress (no file access)
- A real file in the root wins. The same
!-frule that makes the file route work means a leftover physicalllms.txtis served instead of your code, silently. If you are editing code and seeing old text, look for the file. - Forgetting the flush. This is the single commonest failure and it looks exactly like the code not working.
- Reaching for a page slug instead. A page cannot be called
llms.txt: WordPress converts the period to a dash, documented in its own slug function. - A plugin that also claims the path. Two rules for one path is a coin toss. Search your plugins for
llmsbefore adding another.
verify it
Prove the file is really there
A file that looks published in an admin screen and returns anything other than a plain 200 at the exact path has not been published. Three checks, in order:
- Open
https://yourdomain/llms.txtin a private window. You want the raw text, not a styled page, and not a redirect to another path. - Confirm the first line is a level-one Markdown heading —
# Your Business. Google’s agent-readiness audit fails a file with no H1 heading anywhere in it, and the llms.txt specification puts the H1 first, so first is the safe place for it. - Confirm at least one Markdown link is present, in
[label](https://…)form. A file with no links in that form is reported as a failure by the same audit.
Then run it through the validator, which checks the same conditions and tells you which recommendation each one comes from. The package passes the llms.txt and page-structure checks of Google’s agent-readiness audit; the WebMCP audits cover interactive tools a fact package deliberately does not install. That is the claim we make about this file, and the only one. It does not improve your search position.
the honest part
This file is the compliance surface, not the mechanism
Publishing it is worth doing and takes ten minutes. What it will not do on its own is get you found: in a controlled test, agents given no pointer to the file opened it 0 times in 18 visits (Note 15), and in a census of nine real sites, seven published one and not one of them placed it where it gets read (Note 09).
What moved the numbers was putting the answers in the homepage itself, where a one-page reader lands: 78% of fact checks recovered against 30% in the control, with agents stopping after 1.1 pages on average (Note 41). Do this file because Google’s page-quality tooling checks for it and the package passes the llms.txt and page-structure checks of Google’s agent-readiness audit; the WebMCP audits cover interactive tools a fact package deliberately does not install. Do the fact block because it works.
Sources: MARKETING_NOTES_AGENT_VISIBILITY.md, Notes 09, 15, 41.
If somebody has told you this file moves your search position, read does llms.txt help SEO first — the answer is documented, and it is not the one they gave you.
other platforms
The same job elsewhere
free audit
See what AI sees on your site
The file is ten minutes of work. Whether your homepage answers a buyer's question is a different question, and it is the one we measure.
One model fetches your homepage and answers buyer questions from it. You get the recovery score and the specific answers it could not find. That is the whole free tier: it shows you the problem, and the fix package is not included.