# WordPress SEO for ChatGPT, Perplexity and AI search

> Get your WordPress site into ChatGPT and AI search: virtual robots.txt and robots_txt filter, adding llms.txt, JSON-LD via wp_head, and wp-sitemap.xml.

Canonical page: https://getrankroot.com/builders/wordpress · CMS · checked 2026-10-18

What WordPress's own documentation says about how AI crawlers see sites built with it, and the exact settings for robots.txt, llms.txt, structured data and the sitemap.

## How WordPress delivers pages to crawlers

**Built from theme templates per request** (HTML without JavaScript (documented))

WordPress's developer docs say its template loader decides which theme template to load for each URL, and templates generate the page's document structure. Plugins or page builders that load content with JavaScript can change what crawlers see, so check your page source or run RankRoot's audit. This guide covers self-hosted WordPress (the WordPress.org software).

Why it matters: many AI crawlers don't run JavaScript. If your text only appears after scripts run, they may see an empty page.

## What we found on 131 WordPress sites we track

Average AI visibility score 84/100 · 2% only show page text after JavaScript runs · 54% have no llms.txt (crawl up to 2026-10-18).

## Make your content readable without JavaScript

1. Go to **Settings** > **Reading** and make sure **Discourage search engines from indexing this site** is unchecked. When it's checked, WordPress adds a `noindex, nofollow` robots meta tag to every page, and core sitemaps are disabled.
2. Run the [free audit](https://getrankroot.com/#scan) on your homepage and a post to confirm the content is in the HTML.

## robots.txt: let AI search crawlers in

1. WordPress outputs a virtual `robots.txt` (the `do_robots()` function). By default it contains `User-agent: *`, a Disallow line for the admin path, an Allow line for `admin-ajax.php`, and a reference to the core sitemap.
2. Add rules with the `robots_txt` filter in a small plugin or your theme's `functions.php`. The filter receives the generated text and whether the site is public.
3. If a physical `robots.txt` file exists in your site's root folder, edit that file instead, then open `yourdomain.com/robots.txt` to see what's actually served.
4. SEO plugins often include a robots.txt editor. Our [free WordPress plugin](https://getrankroot.com/wordpress) has presets such as "Allow AI search, block training".

Allow AI search crawlers with the robots_txt filter:

```
add_filter( 'robots_txt', function ( $output, $public ) {
    if ( ! $public ) {
        return $output;
    }
    // A crawler that matches this group ignores the * group, so repeat the admin rules.
    $output .= "\nUser-agent: OAI-SearchBot\nUser-agent: PerplexityBot\nUser-agent: Claude-SearchBot\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n";
    return $output;
}, 10, 2 );
```

## Add llms.txt

1. WordPress core has no llms.txt feature.
2. On self-hosted WordPress you can upload a plain `llms.txt` file to the site's root folder (the one with `wp-config.php`) using your host's file manager or SFTP. Write it with the [llms.txt generator](https://getrankroot.com/tools/llms-txt-generator).
3. Or use a plugin that builds it from your pages and posts, such as our [free WordPress plugin](https://getrankroot.com/wordpress). See the [llms.txt for WordPress guide](https://getrankroot.com/guides/llms-txt-wordpress).
4. Open `yourdomain.com/llms.txt` and check it with the [llms.txt validator](https://getrankroot.com/tools/llms-txt-validator).

## Add JSON-LD and head code

1. Themes call `wp_head()` in the page `<head>`. Hook into the `wp_head` action to print a JSON-LD script.
2. SEO plugins usually add Organization and WebSite schema already, so check your page source to avoid duplicates.

Print Organization JSON-LD on the home page via wp_head:

```
add_action( 'wp_head', function () {
    if ( ! is_front_page() ) {
        return;
    }
    $data = array(
        '@context' => 'https://schema.org',
        '@type'    => 'Organization',
        'name'     => get_bloginfo( 'name' ),
        'url'      => home_url( '/' ),
    );
    echo '<script type="application/ld+json">' . wp_json_encode( $data ) . '</script>';
} );
```

## Sitemap

1. Since WordPress 5.5, core publishes a sitemap index at `/wp-sitemap.xml` and references it in `robots.txt`.
2. Core sitemaps are disabled when the site discourages search engines. They can also be turned off with the `wp_sitemaps_enabled` filter, which some plugins do when they provide their own sitemap.
3. Submit whichever sitemap your site actually serves in Google Search Console.

## Common mistakes

- Leaving "Discourage search engines" on after launch. WordPress adds noindex to every page and disables core sitemaps.
- Uploading a physical robots.txt and then wondering why filter- or plugin-based rules don't show up. Check what yourdomain.com/robots.txt actually returns.
- Outputting JSON-LD twice: once from the theme or an SEO plugin and once from custom code.
- Following self-hosted steps on a hosted WordPress plan that doesn't give you file or plugin access. Check what your host allows.

## FAQ

### Does WordPress create llms.txt?

Not in core. Upload a static llms.txt to your site root, or use a plugin that generates it, such as RankRoot's free WordPress plugin.

### How do I edit robots.txt in WordPress?

WordPress serves a virtual robots.txt. Add rules with the robots_txt filter, an SEO plugin's editor, or, if a physical robots.txt exists in your site root, by editing that file.

### Where is my WordPress sitemap?

Core WordPress (5.5 and later) publishes /wp-sitemap.xml unless the site discourages search engines or a plugin disables it to provide its own.

### Is my WordPress site visible to ChatGPT?

WordPress builds pages from your theme's templates when they're requested, so content is normally in the HTML. Check that search engine visibility is on, robots.txt allows OAI-SearchBot, and run the free audit to confirm.

## Sources

- [WordPress Developer: Template hierarchy (read 2026-10-18)](https://developer.wordpress.org/themes/templates/template-hierarchy/)
- [WordPress Developer: do_robots() (read 2026-10-18)](https://developer.wordpress.org/reference/functions/do_robots/)
- [WordPress Developer: robots_txt hook (read 2026-10-18)](https://developer.wordpress.org/reference/hooks/robots_txt/)
- [WordPress Developer: wp_head hook (read 2026-10-18)](https://developer.wordpress.org/reference/hooks/wp_head/)
- [Make WordPress Core: New XML sitemaps functionality in WordPress 5.5 (read 2026-10-18)](https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/)
- [WordPress Documentation: Settings Reading screen (read 2026-10-18)](https://wordpress.org/documentation/article/settings-reading-screen/)

RankRoot is not affiliated with WordPress. Check a live site: https://getrankroot.com/ or `GET https://getrankroot.com/api/audit?url=example.com`. Other builders: https://getrankroot.com/builders.md
