Support Log in

16. XML Sitemap

Developer Guide
Prefer video? Watch the Rank Forge tutorials 9 short guides covering every feature Watch

Rank Forge generates a complete XML sitemap system with a sitemap index, per-post-type sitemaps, and a separate video sitemap that the index does not list. This is a FREE feature.

Endpoints

URLDescription
/sitemap.xmlServes the same sitemap index as /sitemap_index.xml; it does not redirect
/sitemap_index.xmlSitemap index listing the per-post-type sitemaps; the video sitemap is not in it
/{posttype}-sitemap.xmlPer-post-type sitemap (e.g. /post-sitemap.xml)
/video-sitemap.xmlVideo sitemap: published posts with a video that Rank Forge found in the post content when the post was saved (a YouTube or Vimeo link, or an HTML5 video tag with a src attribute), one video per post

Features

  • Respects _rankforge_noindex — noindex posts are excluded from all sitemaps
  • Includes <image:image> elements for featured images
  • Cached via transients with a 1-hour TTL per sitemap
  • Configurable max URLs per sitemap (default 1000)

Configuration

The post types in the sitemap are not set in this option. Every public post type except attachments is listed in the sitemap index once it has a published post, and a post type is left out when “Show in search results” is switched off for it (see Extending the Sitemap). The option rankforge_sitemap_settings holds the maximum number of URLs per sitemap, the same value as the Max URLs per sitemap field in the XML Sitemap card of the Settings screen (100 to 50000 there). Its enabled_types key is ignored.

php
// Set the maximum number of URLs per sitemap (default 1000)
update_option( 'rankforge_sitemap_settings', [
    'max_urls' => 2000,
] );

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

Disabling the Sitemap

Removing the render_sitemap callback from template_redirect stops Rank Forge from printing the sitemap XML. The rewrite rules for the sitemap URLs are registered earlier, on init at priority 10, and this example leaves them in place.

php
add_action( 'init', function () {
    if ( ! class_exists( 'RANKFORGE_Sitemap' ) ) {
        return;
    }
    $sitemap = RANKFORGE_Sitemap::instance();
    remove_action( 'template_redirect', [ $sitemap, 'render_sitemap' ] );
}, 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 Rank Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs