44. Multisite Compatibility | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

44. Multisite Compatibility

Developer Guide

SEO Forge works on WordPress Multisite installations. Each site in the network has its own independent SEO configuration.

Per-Site Configuration

All options, database tables, and post meta are scoped to the individual site. Network-activating SEO Forge creates tables on each site via the wpmu_new_blog hook.

php
// On a multisite, access a specific site's SEO data
switch_to_blog( 2 );
$settings = get_option( 'seoforge_settings', [] );
$analyzer = SEOFORGE_Analyzer::instance();
$stats    = SEOFORGE_Dashboard::instance()->get_stats();
restore_current_blog();

Network-Wide SEO Report

php
// Generate a network-wide SEO summary
$sites = get_sites( [ 'number' => 100 ] );
$report = [];

foreach ( $sites as $site ) {
    switch_to_blog( $site->blog_id );

    if ( ! class_exists( 'SEOFORGE_Dashboard' ) ) {
        restore_current_blog();
        continue;
    }

    $stats = SEOFORGE_Dashboard::instance()->get_stats();
    $report[] = [
        'blog_id'   => $site->blog_id,
        'domain'    => $site->domain . $site->path,
        'avg_score' => $stats['avg_score'] ?? 0,
        'total'     => $stats['total_analyzed'] ?? 0,
    ];

    restore_current_blog();
}

// Sort by average score ascending (worst first)
usort( $report, fn( $a, $b ) => $a['avg_score'] <=> $b['avg_score'] );

Network Activation

When network-activated, SEO Forge creates its database tables on every existing site and on any newly created sites:

php
// Manually trigger table creation on a specific site (if needed)
switch_to_blog( $blog_id );
SEOFORGE_Redirects::create_table();
restore_current_blog();

Forge AI Assistant Online

Hi! I'm the SEO Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs