16. XML Sitemap | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

16. XML Sitemap

Developer Guide

SEO Forge generates a complete XML sitemap system with a sitemap index, per-post-type sitemaps, and an optional video sitemap. This is a FREE feature.

Endpoints

URLDescription
/sitemap.xmlAlias that redirects to the sitemap index
/sitemap_index.xmlSitemap index listing all sub-sitemaps
/{posttype}-sitemap.xmlPer-post-type sitemap (e.g. /post-sitemap.xml)
/video-sitemap.xmlVideo sitemap (PRO)

Features

  • Respects _seoforge_noindex — noindex posts are excluded from all sitemaps
  • Includes elements for featured images
  • Cached via transients with a 1-hour TTL per sitemap
  • Pings Google on post publish via transition_post_status hook
  • Configurable max URLs per sitemap (default 1000)

Configuration

php
// Customize which post types appear in the sitemap
update_option( 'seoforge_sitemap_settings', [
    'enabled_types' => [ 'post', 'page', 'product' ],
    'max_urls'      => 2000,
] );

// Invalidate sitemap cache programmatically
SEOFORGE_Sitemap::instance()->invalidate_cache();

Disabling the Sitemap

php
add_action( 'init', function () {
    if ( ! class_exists( 'SEOFORGE_Sitemap' ) ) {
        return;
    }
    $sitemap = SEOFORGE_Sitemap::instance();
    remove_action( 'init', [ $sitemap, 'register_rewrites' ] );
    remove_action( 'template_redirect', [ $sitemap, 'render_sitemap' ] );
    remove_action( 'transition_post_status', [ $sitemap, 'maybe_ping_google' ] );
}, 20 );

Flush Rewrite Rules

After activation or if sitemaps return 404:

php
flush_rewrite_rules();
// Or from WP-CLI: wp rewrite flush

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