Menu

Developers / WordPress Integration

WordPress Integration

How to integrate Topmast with WordPress using our official plugin.

Overview

The Topmast WordPress plugin handles all API communication automatically. This guide covers how the integration works and how to customize it.

Installation

The plugin isn't in the WordPress.org plugin directory yet: it is installed from a ZIP file you download from the

dashboard (Sites → Download plugin, with a plan or a trial).

Via WordPress Admin

  1. Go to Plugins > Add New > Upload Plugin
  2. Upload the ZIP file and activate

Via WP-CLI

Bash
wp plugin install ./topmast-X.Y.Z.zip --activate

Once connected, the plugin keeps itself up to date from Topmast.

Initial Setup

1. Connect Your Site

  1. Navigate to Topmast → Settings in WordPress admin
  2. Click Connect to Topmast
  3. Log in to your Topmast account
  4. Confirm the site on the page that opens; WordPress comes back connected

Behind the button, WordPress asks Topmast for a single-use code (server to server), the browser carries only that code

to the dashboard, and after you confirm, WordPress claims the site's API key server to server. Before handing the key

over, Topmast checks the site itself answers for that code at /?topmast_connect_proof=…, so a connect started from

anywhere else can't take the key. Re-connecting a site that is already in your account gives it a new key. You can

still paste a key by hand under Or paste an API key.

2. Run Initial Scan

Bash
wp topmast scan --force

Or click Scan Site in the admin dashboard.

3. Generate LLMs.txt

Bash
wp topmast llms-txt generate

How It Works

Content Sync Flow

text
WordPress → Scan Content → Transform → POST /api/sites/sync → Database
  1. Plugin scans pages, posts, and custom post types
  2. Content is transformed to sync payload format
  3. Inventory is sent to Topmast API
  4. Readiness score is calculated and stored

LLMs.txt Generation

text
GET /api/sites/{id}/llms-txt → Generate → Cache → Return
  1. Plugin requests LLMs.txt from API
  2. API generates content using AI
  3. Content is cached locally
  4. File is served at /llms.txt

Plugin Settings

General Settings

SettingDescriptionDefault
Auto-syncSync on content publishEnabled
Sync intervalHow often to full syncDaily
Include draftsInclude draft postsDisabled

Content Settings

SettingDescriptionDefault
Post typesWhich types to includepage, post
Exclude categoriesCategories to skipNone
Max pagesMaximum pages to sync500

LLMs.txt Settings

SettingDescriptionDefault
Auto-regenerateRegenerate on syncDisabled
Cache durationHow long to cache24 hours

Hooks and Filters

Modify Sync Payload

PHP
add_filter('topmast_sync_payload', function($payload, $site_id) {
    // Add custom data to sync
    $payload['custom_field'] = 'value';
    return $payload;
}, 10, 2);

Exclude Posts from Scan

PHP
add_filter('topmast_scan_exclude_post', function($exclude, $post) {
    // Exclude posts with specific meta
    if (get_post_meta($post->ID, 'hide_from_ai', true)) {
        return true;
    }
    return $exclude;
}, 10, 2);

Customize LLMs.txt Content

PHP
add_filter('topmast_llms_txt_content', function($content, $site_data) {
    // Add custom section
    $content .= "\n\n## Custom Section\nAdditional content...";
    return $content;
}, 10, 2);

Before/After Sync Actions

PHP
add_action('topmast_before_sync', function($site_id) {
    // Run before sync starts
    error_log('Starting sync for site: ' . $site_id);
});

add_action('topmast_after_sync', function($site_id, $result) {
    // Run after sync completes
    if ($result['success']) {
        error_log('Sync completed: ' . $result['pages_synced'] . ' pages');
    }
}, 10, 2);

WP-CLI Commands

Full CLI documentation:

Bash
wp topmast --help

Common Commands

Bash
# Check connection status
wp topmast status

# Validate API key
wp topmast validate

# Run content scan
wp topmast scan --force

# Sync inventory
wp topmast sync

# Generate LLMs.txt
wp topmast llms-txt generate

# View summaries
wp topmast summaries list

Troubleshooting

Connection Issues

Bash
# Test API connectivity
wp topmast validate --debug

Sync Failures

  1. Check error logs: Topmast > Logs
  2. Verify API key is valid
  3. Check server can reach topmast.app and aioradar.vercel.app (the addresses the plugin calls)

LLMs.txt Not Updating

Bash
# Force regeneration
wp topmast llms-txt generate --force

# Clear cache
wp topmast llms-txt clear

Rewrite Rules Not Working

Bash
# Flush permalinks
wp rewrite flush

Or visit Settings > Permalinks and click Save.